diff --git a/src/cursor.rs b/src/cursor.rs index f7c5056b8423b59446f4bb2335526adee1345996..04bb4e03bc0e08838ee5bef7d950a6ceb48b5fad 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -8,6 +8,18 @@ use bevy::{input::mouse::MouseMotion, prelude::*, window::PrimaryWindow}; #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)] pub struct CursorSet; +/// Config enum for mouse cursor events. +#[derive(Default, Clone)] +pub enum CursorConfig { + /// Emit [`TextHoverIn`] and [`TextHoverOut`] events and change mouse cursor on hover + #[default] + Default, + /// Emit [`TextHoverIn`] and [`TextHoverOut`] events, but do not change the cursor + Events, + /// Ignore mouse events + None, +} + pub(crate) struct CursorPlugin { pub change_cursor: CursorConfig, } diff --git a/src/input.rs b/src/input.rs index 7d292ee6565804d923b8b5e6c84b8ebfbd7d481e..8aae13b76cda14769991d5cf658fc0796e2e7543 100644 --- a/src/input.rs +++ b/src/input.rs @@ -38,16 +38,19 @@ impl Plugin for InputPlugin { } } +/// Timer for double / triple clicks #[derive(Resource)] pub struct ClickTimer(pub Timer); // TODO: hide this behind #cfg wasm, depends on wasm having own copy/paste fn +/// Crossbeam channel struct for Wasm clipboard data #[allow(dead_code)] pub struct WasmPaste { text: String, entity: Entity, } +/// Async channel for receiving from the clipboard in Wasm #[derive(Resource)] pub struct WasmPasteAsyncChannel { pub tx: crossbeam_channel::Sender<WasmPaste>, diff --git a/src/lib.rs b/src/lib.rs index 3c425698f73527e92611121aaf3b3181be8ba8d1..17beeed3dc21ec8e71e3338948495228a01b8c41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,14 +72,6 @@ impl Plugin for CosmicEditPlugin { #[derive(Component)] pub struct CosmicPrimaryCamera; -#[derive(Default, Clone)] -pub enum CursorConfig { - #[default] - Default, - Events, - None, -} - /// Resource struct that holds configuration options for cosmic fonts. #[derive(Resource, Clone)] pub struct CosmicFontConfig { diff --git a/src/placeholder.rs b/src/placeholder.rs index 0fc5b21be94a5cb2c4283fd3e95d16491e08fbbf..a7b4797c9cdef71ed834359144ed23c6a1f92fc9 100644 --- a/src/placeholder.rs +++ b/src/placeholder.rs @@ -7,9 +7,7 @@ use cosmic_text::{Attrs, Edit}; /// ``` /// # use bevy::prelude::*; /// # use bevy_cosmic_edit::*; -/// # /// # fn setup(mut commands: Commands) { -/// // Create a new cosmic bundle /// commands.spawn((CosmicEditBundle { /// sprite_bundle: SpriteBundle { /// sprite: Sprite { @@ -20,10 +18,9 @@ use cosmic_text::{Attrs, Edit}; /// }, /// ..default() /// }, -/// Placeholder::new("Email", Attrs::new().color(Color::GRAY.to_cosmic()), +/// Placeholder::new("Email", Attrs::new().color(Color::GRAY.to_cosmic())), /// )); /// # } -/// # /// # fn main() { /// # App::new() /// # .add_plugins(MinimalPlugins) diff --git a/src/util.rs b/src/util.rs index be8d84c470083e0b75c324ebff9b74f9cecc17d6..e51860883568460be40f13a4316d8869e9e1444a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -18,7 +18,7 @@ impl ColorExtras for Color { } } -/// System to unfocus editors when [Esc] is pressed +/// System to unfocus editors when \[Esc\] is pressed pub fn deselect_editor_on_esc(i: Res<ButtonInput<KeyCode>>, mut focus: ResMut<FocusedWidget>) { if i.just_pressed(KeyCode::Escape) { focus.0 = None;