pub trait EntityInputHandler: 'static + Sized {
// 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 method
fn accepts_text_input(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> bool { ... }
}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.
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 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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.