Struct cursive_core::views::CircularFocus
source · pub struct CircularFocus<T: View> { /* private fields */ }
Expand description
Adds circular focus to a wrapped view.
Wrap a view in CircularFocus
to enable wrap-around focus
(when the focus exits this view, it will come back the other side).
It can be configured to wrap Tab (and Shift+Tab) keys, and/or Arrow keys.
Implementations§
source§impl<T: View> CircularFocus<T>
impl<T: View> CircularFocus<T>
sourcepub fn new(view: T) -> Self
pub fn new(view: T) -> Self
Creates a new CircularFocus
around the given view.
Does not wrap anything by default, so you’ll want to call one of the setters.
sourcepub fn wraps_arrows(&self) -> bool
pub fn wraps_arrows(&self) -> bool
Returns true
if Arrow keys cause focus to wrap around.
sourcepub fn wraps_left_right(&self) -> bool
pub fn wraps_left_right(&self) -> bool
Return true
if left/right keys cause focus to wrap around.
sourcepub fn wraps_up_down(&self) -> bool
pub fn wraps_up_down(&self) -> bool
Return true
if up/down keys cause focus to wrap around.
sourcepub fn wrap_arrows(self) -> Self
pub fn wrap_arrows(self) -> Self
Make this view now wrap focus around when arrow keys are pressed.
sourcepub fn wrap_up_down(self) -> Self
pub fn wrap_up_down(self) -> Self
Make this view now wrap focus around when the up/down keys are pressed.
sourcepub fn wrap_left_right(self) -> Self
pub fn wrap_left_right(self) -> Self
Make this view now wrap focus around when the left/right keys are pressed.
sourcepub fn with_wrap_tab(self, wrap_tab: bool) -> Self
pub fn with_wrap_tab(self, wrap_tab: bool) -> Self
Make this view now wrap focus around when the Tab key is pressed.
Chainable variant.
sourcepub fn wrap_tab(self) -> Self
pub fn wrap_tab(self) -> Self
Make this view now wrap focus around when the Tab key is pressed.
Chainable variant.
sourcepub fn with_wrap_left_right(self, wrap_left_right: bool) -> Self
pub fn with_wrap_left_right(self, wrap_left_right: bool) -> Self
Make this view now wrap focus around when the left/right keys are pressed.
sourcepub fn with_wrap_up_down(self, wrap_up_down: bool) -> Self
pub fn with_wrap_up_down(self, wrap_up_down: bool) -> Self
Make this view now wrap focus around when the up/down keys are pressed.
sourcepub fn with_wrap_arrows(self, wrap_arrows: bool) -> Self
pub fn with_wrap_arrows(self, wrap_arrows: bool) -> Self
Make this view now wrap focus around when arrow keys are pressed.
sourcepub fn set_wrap_tab(&mut self, wrap_tab: bool)
pub fn set_wrap_tab(&mut self, wrap_tab: bool)
Make this view now wrap focus around when the Tab key is pressed.
sourcepub fn set_wrap_arrows(&mut self, wrap_arrows: bool)
pub fn set_wrap_arrows(&mut self, wrap_arrows: bool)
Make this view now wrap focus around when arrow keys are pressed.
sourcepub fn set_wrap_up_down(&mut self, wrap_up_down: bool)
pub fn set_wrap_up_down(&mut self, wrap_up_down: bool)
Make this view now wrap focus around when the up/down keys are pressed.
sourcepub fn set_wrap_left_right(&mut self, wrap_left_right: bool)
pub fn set_wrap_left_right(&mut self, wrap_left_right: bool)
Make this view now wrap focus around when the left/right keys are pressed.
sourcepub fn get_inner_mut(&mut self) -> &mut T
pub fn get_inner_mut(&mut self) -> &mut T
Gets mutable access to the inner view.
Trait Implementations§
source§impl<T: View> ViewWrapper for CircularFocus<T>
impl<T: View> ViewWrapper for CircularFocus<T>
source§fn with_view<F, R>(&self, f: F) -> Option<R>where
F: FnOnce(&Self::V) -> R,
fn with_view<F, R>(&self, f: F) -> Option<R>where
F: FnOnce(&Self::V) -> R,
source§fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>where
F: FnOnce(&mut Self::V) -> R,
fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>where
F: FnOnce(&mut Self::V) -> R,
source§fn into_inner(self) -> Result<Self::V, Self>where
Self::V: Sized,
fn into_inner(self) -> Result<Self::V, Self>where
Self::V: Sized,
source§fn wrap_on_event(&mut self, event: Event) -> EventResult
fn wrap_on_event(&mut self, event: Event) -> EventResult
on_event
method.source§fn wrap_required_size(&mut self, req: Vec2) -> Vec2
fn wrap_required_size(&mut self, req: Vec2) -> Vec2
required_size
method.source§fn wrap_layout(&mut self, size: Vec2)
fn wrap_layout(&mut self, size: Vec2)
layout
method.source§fn wrap_take_focus(
&mut self,
source: Direction
) -> Result<EventResult, CannotFocus>
fn wrap_take_focus(
&mut self,
source: Direction
) -> Result<EventResult, CannotFocus>
take_focus
method.source§fn wrap_call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>)
fn wrap_call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>)
find
method.source§fn wrap_focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<EventResult, ViewNotFound>
fn wrap_focus_view(
&mut self,
selector: &Selector<'_>
) -> Result<EventResult, ViewNotFound>
focus_view
method.source§fn wrap_needs_relayout(&self) -> bool
fn wrap_needs_relayout(&self) -> bool
needs_relayout
method.source§fn wrap_important_area(&self, size: Vec2) -> Rect
fn wrap_important_area(&self, size: Vec2) -> Rect
important_area
method.