EntityInputHandler

Trait EntityInputHandler 

Source
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§

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 accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool

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.

Implementors§