Trait gpui2::InputHandler
source · pub trait InputHandler: 'static + Sized {
// Required methods
fn text_for_range(
&mut self,
range: Range<usize>,
cx: &mut ViewContext<'_, Self>
) -> Option<String>;
fn selected_text_range(
&mut self,
cx: &mut ViewContext<'_, Self>
) -> Option<Range<usize>>;
fn marked_text_range(
&self,
cx: &mut ViewContext<'_, Self>
) -> Option<Range<usize>>;
fn unmark_text(&mut self, cx: &mut ViewContext<'_, Self>);
fn replace_text_in_range(
&mut self,
range: Option<Range<usize>>,
text: &str,
cx: &mut ViewContext<'_, Self>
);
fn replace_and_mark_text_in_range(
&mut self,
range: Option<Range<usize>>,
new_text: &str,
new_selected_range: Option<Range<usize>>,
cx: &mut ViewContext<'_, Self>
);
fn bounds_for_range(
&mut self,
range_utf16: Range<usize>,
element_bounds: Bounds<Pixels>,
cx: &mut ViewContext<'_, Self>
) -> Option<Bounds<Pixels>>;
}
Expand description
Implement this trait to allow views to handle textual input when implementing an editor, field, etc.
Once your view V
implements this trait, you can use it to construct an ElementInputHandler