ferroui_base/input/i_input_element.rs
1use super::{Cursor, KeyModifiers, NavigationMethod};
2use std::rc::Rc;
3
4/// Defines input-related functionality for a control.
5///
6/// The only implementor is `InputElement`: object references to input
7/// elements are `Ref<InputElement>`. The trait documents the contract; the
8/// routed event members of the contract (`add_handler`, `remove_handler`,
9/// `raise_event`) are inherited by every input element from `Interactive`.
10pub trait IInputElement {
11 /// Whether the control can receive keyboard focus.
12 fn focusable(&self) -> bool;
13
14 /// Whether the control is enabled for user interaction.
15 fn is_enabled(&self) -> bool;
16
17 /// The associated mouse cursor.
18 fn cursor(&self) -> Option<Rc<Cursor>>;
19
20 /// Whether this control and all its parents are enabled.
21 ///
22 /// `is_enabled` is used to toggle the enabled state for individual
23 /// controls. This property takes into account the enabled state of this
24 /// control and its parent controls.
25 fn is_effectively_enabled(&self) -> bool;
26
27 /// Whether this control and all its parents are visible.
28 fn is_effectively_visible(&self) -> bool;
29
30 /// Whether keyboard focus is anywhere within the element or its visual
31 /// tree child elements.
32 fn is_keyboard_focus_within(&self) -> bool;
33
34 /// Whether the control is focused.
35 fn is_focused(&self) -> bool;
36
37 /// Whether the control is considered for hit testing.
38 fn is_hit_test_visible(&self) -> bool;
39
40 /// Whether the pointer is currently over the control.
41 fn is_pointer_over(&self) -> bool;
42
43 /// Focuses the control. Returns whether the control was focused.
44 fn focus(&self, method: NavigationMethod, key_modifiers: KeyModifiers) -> bool;
45}