Skip to main content

EntityInputHandler

Trait EntityInputHandler 

Source
pub trait EntityInputHandler: 'static + Sized {
Show 15 methods // Required methods fn text_for_range( &mut self, range: Range<usize>, adjusted_range: &mut Option<Range<usize>>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<String>; fn selected_text_range( &mut self, ignore_disabled_input: bool, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<UTF16Selection>; fn marked_text_range( &self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>; fn unmark_text(&mut self, window: &mut Window, cx: &mut Context<'_, Self>); fn replace_text_in_range( &mut self, range: Option<Range<usize>>, text: &str, window: &mut Window, cx: &mut Context<'_, Self>, ); fn replace_and_mark_text_in_range( &mut self, range: Option<Range<usize>>, new_text: &str, new_selected_range: Option<Range<usize>>, window: &mut Window, cx: &mut Context<'_, Self>, ); fn bounds_for_range( &mut self, range_utf16: Range<usize>, element_bounds: Bounds<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>; fn character_index_for_point( &mut self, point: Point<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<usize>; // Provided methods fn paste( &mut self, item: ClipboardItem, window: &mut Window, cx: &mut Context<'_, Self>, ) { ... } fn selection_bounds_for_range( &mut self, _range_utf16: Range<usize>, _element_bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Vec<Bounds<Pixels>> { ... } fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) { ... } fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize> { ... } fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool { ... } fn text_input_configuration( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> TextInputConfiguration { ... } fn text_input_editable_range( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>> { ... }
}
Expand description

Implement this trait to allow views to handle textual input when implementing an editor, field, etc.

Once your view implements this trait, you can use it to construct an ElementInputHandler<V>. This input handler can then be assigned during paint by calling Window::handle_input.

Dismissing the software keyboard can leave the component focused. Call Window::request_virtual_keyboard from an editing gesture, such as tapping the field, to reopen it; repainting alone should not undo a dismissal.

After application-driven edits or selection changes, also call Window::notify_text_input_changed or Window::notify_text_selection_changed so native text services can invalidate their state.

UIKit text input also needs text_length_utf16 (or a bounded text_input_editable_range) and native selection updates through set_selected_text_range. Supply selection_bounds_for_range for native selection rectangles; it should return line/run fragments in one batch.

See InputHandler for details on how to implement each method.

Required Methods§

Source

fn text_for_range( &mut self, range: Range<usize>, adjusted_range: &mut Option<Range<usize>>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<String>

Source

fn selected_text_range( &mut self, ignore_disabled_input: bool, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<UTF16Selection>

Source

fn marked_text_range( &self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>

Source

fn unmark_text(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)

See InputHandler::unmark_text for details

Source

fn replace_text_in_range( &mut self, range: Option<Range<usize>>, text: &str, window: &mut Window, cx: &mut Context<'_, Self>, )

Source

fn replace_and_mark_text_in_range( &mut self, range: Option<Range<usize>>, new_text: &str, new_selected_range: Option<Range<usize>>, window: &mut Window, cx: &mut Context<'_, Self>, )

Source

fn bounds_for_range( &mut self, range_utf16: Range<usize>, element_bounds: Bounds<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>

Source

fn character_index_for_point( &mut self, point: Point<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<usize>

Provided Methods§

Source

fn paste( &mut self, item: ClipboardItem, window: &mut Window, cx: &mut Context<'_, Self>, )

See InputHandler::paste for details

Source

fn selection_bounds_for_range( &mut self, _range_utf16: Range<usize>, _element_bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Vec<Bounds<Pixels>>

Source

fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, )

Source

fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>

Source

fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool

Source

fn text_input_configuration( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> TextInputConfiguration

Source

fn text_input_editable_range( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§