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§
Sourcefn text_for_range(
&mut self,
range: Range<usize>,
adjusted_range: &mut Option<Range<usize>>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Option<String>
fn text_for_range( &mut self, range: Range<usize>, adjusted_range: &mut Option<Range<usize>>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<String>
See InputHandler::text_for_range for details
Sourcefn selected_text_range(
&mut self,
ignore_disabled_input: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Option<UTF16Selection>
fn selected_text_range( &mut self, ignore_disabled_input: bool, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<UTF16Selection>
See InputHandler::selected_text_range for details
Sourcefn marked_text_range(
&self,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn marked_text_range( &self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>
See InputHandler::marked_text_range for details
Sourcefn unmark_text(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
fn unmark_text(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
See InputHandler::unmark_text for details
Sourcefn replace_text_in_range(
&mut self,
range: Option<Range<usize>>,
text: &str,
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>, )
See InputHandler::replace_text_in_range for details
Sourcefn 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 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>, )
See InputHandler::replace_and_mark_text_in_range for details
Sourcefn bounds_for_range(
&mut self,
range_utf16: Range<usize>,
element_bounds: Bounds<Pixels>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Option<Bounds<Pixels>>
fn bounds_for_range( &mut self, range_utf16: Range<usize>, element_bounds: Bounds<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>
See InputHandler::bounds_for_range for details
Sourcefn character_index_for_point(
&mut self,
point: Point<Pixels>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Option<usize>
fn character_index_for_point( &mut self, point: Point<Pixels>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<usize>
See InputHandler::character_index_for_point for details
Provided Methods§
Sourcefn paste(
&mut self,
item: ClipboardItem,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn paste( &mut self, item: ClipboardItem, window: &mut Window, cx: &mut Context<'_, Self>, )
See InputHandler::paste for details
Sourcefn 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 selection_bounds_for_range( &mut self, _range_utf16: Range<usize>, _element_bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Vec<Bounds<Pixels>>
See InputHandler::selection_bounds_for_range for details.
Sourcefn set_selected_text_range(
&mut self,
_range_utf16: Range<usize>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
)
fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, )
See InputHandler::set_selected_text_range for details
Sourcefn text_length_utf16(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<usize>
fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>
See InputHandler::text_length_utf16 for details
Sourcefn accepts_text_input(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> bool
fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool
See InputHandler::accepts_text_input for details
Sourcefn text_input_configuration(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> TextInputConfiguration
fn text_input_configuration( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> TextInputConfiguration
See InputHandler::text_input_configuration for details
Sourcefn text_input_editable_range(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn text_input_editable_range( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>
See InputHandler::text_input_editable_range for details
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".