zng_ext_input::focus

Struct FOCUS

source
pub struct FOCUS;
Expand description

Keyboard focus service.

§Provider

This service is provided by the FocusManager extension.

Implementations§

source§

impl FOCUS

source

pub fn auto_highlight(&self) -> ArcVar<Option<Duration>>

If set to a duration, starts highlighting focus when a focus change happen within the duration of a keyboard input event.

Default is 300.ms().

source

pub fn focus_disabled_widgets(&self) -> ArcVar<bool>

If DISABLED widgets can receive focus.

This is true by default, allowing disabled widgets to receive focus can provide a better experience for users, as the keyboard navigation stays the same, this is also of special interest for accessibility users, screen readers tend to only vocalize the focused content.

Widgets should use a different focused visual for disabled focus, it must be clear that the widget has the keyboard focus only as a navigation waypoint and cannot provide its normal function.

source

pub fn focus_hidden_widgets(&self) -> ArcVar<bool>

If Hidden widgets can receive focus.

This is true by default, with the expectation that hidden widgets are made visible once they receive focus, this is particularly important to enable auto-scrolling to view, as widgets inside scroll regions that are far away from the viewport are auto-hidden.

Note that widgets can be explicitly made not focusable, so you can disable focus and hide a widget without needing to disable this feature globally. Note also that this feature does not apply to collapsed widgets.

source

pub fn navigation_origin(&self) -> ArcVar<Option<WidgetId>>

Override the starting point of the next focus move.

Focus requests that move the focus relative to the current focus will move from this widget instead if it is found in the focused window. This widget does not need to be focusable.

The variable is cleared every time the focus is moved. Auto focus by click or touch also sets the navigation origin if the clicked widget is not focusable.

If not set the focused widget is the origin.

source

pub fn focused(&self) -> ReadOnlyArcVar<Option<InteractionPath>>

Current focused widget.

source

pub fn return_focused( &self, scope_id: WidgetId, ) -> ReadOnlyArcVar<Option<InteractionPath>>

Current return focus of a scope.

source

pub fn is_window_focused(&self, window_id: WindowId) -> impl Var<bool>

If the focused path is in the given window_id.

source

pub fn is_focus_within(&self, widget_id: WidgetId) -> impl Var<bool>

If the focused path contains the given widget_id.

source

pub fn is_focused(&self, widget_id: WidgetId) -> impl Var<bool>

If the focused path is to the given widget_id.

source

pub fn alt_return(&self) -> ReadOnlyArcVar<Option<InteractionPath>>

Current ALT return focus.

source

pub fn in_alt(&self) -> impl Var<bool>

If focus is in an ALT scope.

source

pub fn is_highlighting(&self) -> ReadOnlyArcVar<bool>

If the current focused widget is visually indicated.

source

pub fn focus(&self, request: FocusRequest)

Request a focus update.

All other focus request methods call this method.

source

pub fn highlight(&self)

Schedules enabling of is_highlighting for next update.

source

pub fn focus_widget(&self, widget_id: impl Into<WidgetId>, highlight: bool)

Focus the widget if it is focusable and change the highlight.

If the widget is not focusable the focus does not move, in this case the highlight changes for the current focused widget.

If the widget is in a window that does not have focus, but is open and not minimized and the app has keyboard focus in another window; the window is focused and the request is processed when the focus event is received. The FocusRequest type has other more advanced window focus configurations.

This makes a focus request using FocusRequest::direct.

source

pub fn focus_widget_or_exit( &self, widget_id: impl Into<WidgetId>, navigation_origin: bool, highlight: bool, )

Focus the widget if it is focusable, else focus the first focusable parent, also changes the highlight.

If the widget and no parent are focusable the focus does not move, in this case the highlight changes for the current focused widget.

If navigation_origin is true the target becomes the navigation_origin when the first focusable ancestor is focused because the target is not focusable.

This makes a focus request using FocusRequest::direct_or_exit.

source

pub fn focus_widget_or_enter( &self, widget_id: impl Into<WidgetId>, navigation_origin: bool, highlight: bool, )

Focus the widget if it is focusable, else focus the first focusable descendant, also changes the highlight.

If the widget and no child are focusable the focus does not move, in this case the highlight changes for the current focused widget.

If navigation_origin is true the target becomes the navigation_origin when the first focusable descendant is focused because the target is not focusable.

This makes a focus request FocusRequest::direct_or_enter.

Focus the widget if it is focusable, else focus the first focusable descendant, else focus the first focusable ancestor.

If the widget no focusable widget is found the focus does not move, in this case the highlight changes for the current focused widget.

If navigation_origin is true the target becomes the navigation_origin when the first focusable relative is focused because the target is not focusable.

This makes a focus request using FocusRequest::direct_or_related.

source

pub fn focus_enter(&self)

Focus the first logical descendant that is focusable from the navigation origin or the current focus.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::enter.

source

pub fn focus_exit(&self)

Focus the first logical ancestor that is focusable from the navigation origin or the current focus or the return focus from ALT scopes.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::exit.

source

pub fn focus_next(&self)

Focus the logical next widget from the navigation origin or the current focus.

Does nothing if no origin of focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::next.

source

pub fn focus_prev(&self)

Focus the logical previous widget from the navigation origin or the current focus.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::prev.

source

pub fn focus_up(&self)

Focus the nearest upward widget from the navigation origin or the current focus.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::up.

source

pub fn focus_right(&self)

Focus the nearest widget to the right of the navigation origin or the current focus.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::right.

source

pub fn focus_down(&self)

Focus the nearest downward widget from the navigation origin or the current focus.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::down.

source

pub fn focus_left(&self)

Focus the nearest widget to the left of the navigation origin or the current focus.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::left.

source

pub fn focus_alt(&self)

Focus the ALT scope from the navigation origin or the current focus or escapes the current ALT scope.

Does nothing if no origin or focus is set. Continues highlighting the new focus if the current is highlighted.

This is makes a focus request using FocusRequest::alt.

Auto Trait Implementations§

§

impl Freeze for FOCUS

§

impl RefUnwindSafe for FOCUS

§

impl Send for FOCUS

§

impl Sync for FOCUS

§

impl Unpin for FOCUS

§

impl UnwindSafe for FOCUS

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> StateValue for T
where T: Any + Send + Sync,