Skip to content
Snippets Groups Projects
Unverified Commit 682f3354 authored by sam edelsten's avatar sam edelsten Committed by GitHub
Browse files

Merge pull request #136 from StaffEngineer/user-select

Optionally disable text selection
parents d250f4c6 283a0edc
No related branches found
No related tags found
No related merge requests found
......@@ -88,6 +88,7 @@ mod input;
mod password;
mod placeholder;
mod render;
mod user_select;
mod util;
mod widget;
......@@ -109,6 +110,7 @@ pub use input::*;
pub use password::*;
pub use placeholder::*;
pub use render::*;
pub use user_select::*;
pub use util::*;
pub use widget::*;
......@@ -132,6 +134,7 @@ impl Plugin for CosmicEditPlugin {
PlaceholderPlugin,
PasswordPlugin,
EventsPlugin,
UserSelectPlugin,
))
.insert_resource(CosmicFontSystem(font_system));
......
use crate::*;
use bevy::prelude::*;
pub(crate) struct UserSelectPlugin;
impl Plugin for UserSelectPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Update, clear_selection.after(InputSet));
}
}
/// Tag component to disable user selection
/// Like CSS `user-select: none` https://developer.mozilla.org/en-US/docs/Web/CSS/user-select
#[derive(Component)]
pub struct UserSelectNone;
fn clear_selection(mut q: Query<&mut CosmicEditor, With<UserSelectNone>>) {
for mut editor in q.iter_mut() {
editor.set_selection(cosmic_text::Selection::None);
}
}
......@@ -126,7 +126,7 @@ pub fn print_editor_text(
if current_text == *previous_value {
return;
}
*previous_value = current_text.clone();
previous_value.clone_from(&current_text);
info!("Widget text: {:?}", current_text);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment