rat_focus

Trait HasFocus

source
pub trait HasFocus {
    // Required methods
    fn focus(&self) -> FocusFlag;
    fn area(&self) -> Rect;

    // Provided methods
    fn build(&self, builder: &mut FocusBuilder) { ... }
    fn z_areas(&self) -> &[ZRect] { ... }
    fn navigable(&self) -> Navigation { ... }
    fn is_focused(&self) -> bool { ... }
    fn lost_focus(&self) -> bool { ... }
    fn gained_focus(&self) -> bool { ... }
}
Expand description

Trait for a widget that has a focus flag.

Required Methods§

source

fn focus(&self) -> FocusFlag

Access to the flag for the rest.

source

fn area(&self) -> Rect

Area for mouse focus.

This area shouldn’t overlap with areas returned by other widgets. If it does, the widget should use z_areas() for clarification. Otherwise, the areas are searched in order of addition.

Provided Methods§

source

fn build(&self, builder: &mut FocusBuilder)

Build the focus-structure for the container.

source

fn z_areas(&self) -> &[ZRect]

The widget might have several disjointed/overlapping areas. This is the case if it is showing a popup, but there might be other causes.

If z_areas() returns an empty slice it defaults to area()+z-index 0.

z_areas() are a higher resolution image of the widgets areas. If a widget returns anything but an empty slice here:

  • area() must be the union of all z_areas. Hit detection will fail for anything outside area()
  • z_areas may overlap other areas. The area with the higher z-index will win the hit-test. If there are still overlapping areas after that, they will be used in the order of addition.
source

fn navigable(&self) -> Navigation

Declares how the widget interacts with focus.

Default is Navigation::Regular.

source

fn is_focused(&self) -> bool

Focused?

source

fn lost_focus(&self) -> bool

Just lost focus.

source

fn gained_focus(&self) -> bool

Just gained focus.

Implementors§