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>
fn with_view<F, R>(&self, f: F) -> Option<R>
source§fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>
fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>
source§fn into_inner(self) -> Result<Self::V, Self>
fn into_inner(self) -> Result<Self::V, Self>
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(&mut self, selector: &Selector<'_>, callback: AnyCb<'_>)
fn wrap_call_on_any(&mut self, selector: &Selector<'_>, callback: AnyCb<'_>)
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.Auto Trait Implementations§
impl<T> Freeze for CircularFocus<T>where
T: Freeze,
impl<T> RefUnwindSafe for CircularFocus<T>where
T: RefUnwindSafe,
impl<T> Send for CircularFocus<T>
impl<T> Sync for CircularFocus<T>
impl<T> Unpin for CircularFocus<T>where
T: Unpin,
impl<T> UnwindSafe for CircularFocus<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Finder for Twhere
T: View,
impl<T> Finder for Twhere
T: View,
source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
sel. Read moresource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
sel. Read moresource§fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
call_on with a view::Selector::Name.source§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere
T: View,
source§fn into_boxed_view(self) -> Box<dyn View>
fn into_boxed_view(self) -> Box<dyn View>
Box<View>.source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere
T: View,
source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint,
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint, ) -> ResizedView<Self>
self in a ResizedView with the given size constraints.source§fn fixed_size<S: Into<Vec2>>(self, size: S) -> ResizedView<Self>
fn fixed_size<S: Into<Vec2>>(self, size: S) -> ResizedView<Self>
self into a fixed-size ResizedView.source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self into a full-screen ResizedView.source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self into a full-width ResizedView.source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self into a full-height ResizedView.source§fn max_size<S: Into<Vec2>>(self, size: S) -> ResizedView<Self>
fn max_size<S: Into<Vec2>>(self, size: S) -> ResizedView<Self>
self into a limited-size ResizedView.source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self into a limited-width ResizedView.source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self into a limited-height ResizedView.source§fn min_size<S: Into<Vec2>>(self, size: S) -> ResizedView<Self>
fn min_size<S: Into<Vec2>>(self, size: S) -> ResizedView<Self>
self into a ResizedView at least sized size.source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self in a ResizedView at least min_width wide.source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self in a ResizedView at least min_height tall.source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere
T: View,
source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self in a ScrollView.