ToggleableKeyboard

Struct ToggleableKeyboard 

Source
pub struct ToggleableKeyboard {
    id: Id,
    rect: Rectangle,
    children: Vec<Box<dyn View>>,
    visible: bool,
    parent_rect: Rectangle,
    number_mode: bool,
}
Expand description

A view component that wraps a keyboard and provides toggle functionality.

This component manages a keyboard view along with a separator line, handling all the complexity of showing/hiding the keyboard, updating the context, and managing focus events.

§Examples

let keyboard = ToggleableKeyboard::new(parent_rect, false);
children.push(Box::new(keyboard) as Box<dyn View>);

// Later, to toggle keyboard visibility:
if let Some(index) = locate::<ToggleableKeyboard>(self) {
    let kb = self.children[index].downcast_mut::<ToggleableKeyboard>().unwrap();
    kb.toggle(hub, rq, context);  // Toggles between hidden/visible
}

Fields§

§id: Id§rect: Rectangle§children: Vec<Box<dyn View>>§visible: bool§parent_rect: Rectangle§number_mode: bool

Implementations§

Source§

impl ToggleableKeyboard

Source

pub fn new(parent_rect: Rectangle, number_mode: bool) -> Self

Creates a new ToggleableKeyboard instance.

The keyboard is initially hidden and must be explicitly shown by calling toggle(...) or set_visible(true, ...).

§Arguments
  • parent_rect - The rectangle of the parent view, used for positioning
  • number_mode - If true, the keyboard starts in number mode
§Returns

A new ToggleableKeyboard instance in hidden state.

Source

pub fn toggle(&mut self, hub: &Hub, rq: &mut RenderQueue, context: &mut Context)

Toggles the keyboard visibility between hidden and visible.

If the keyboard is currently hidden, it will be shown. If the keyboard is currently visible, it will be hidden. When hiding, this clears focus and updates the context.

§Arguments
  • hub - Event hub for sending focus events
  • rq - Render queue for scheduling redraws
  • context - Application context for updating keyboard state
Source

pub fn set_visible( &mut self, visible: bool, hub: &Hub, rq: &mut RenderQueue, context: &mut Context, )

Sets the keyboard visibility to the specified state.

This is more explicit than toggle() when you know whether you want to show or hide the keyboard. If the keyboard is already in the desired state, this is a no-op.

§Arguments
  • visible - true to show the keyboard, false to hide it
  • hub - Event hub for sending focus events
  • rq - Render queue for scheduling redraws
  • context - Application context for updating keyboard state
Source

pub fn set_number_mode(&mut self, number_mode: bool)

Sets the keyboard number mode.

When number mode is enabled, the keyboard displays numbers and symbols instead of letters. This setting only takes effect the next time the keyboard is shown.

§Arguments
  • number_mode - true to enable number mode, false for letter mode
Source

pub fn is_visible(&self) -> bool

Returns whether the keyboard is currently visible.

§Returns

true if the keyboard is visible, false otherwise.

Source

fn show(&mut self, rq: &mut RenderQueue, context: &mut Context)

Shows the keyboard by creating the separator and keyboard views.

This method calculates the proper positioning based on the parent rect and creates both the separator line and the keyboard itself.

Source

fn hide(&mut self, hub: &Hub, rq: &mut RenderQueue, context: &mut Context)

Hides the keyboard by clearing all child views and resetting state.

This method also clears the focus and updates the context to reflect that no keyboard is active.

Trait Implementations§

Source§

impl View for ToggleableKeyboard

Source§

fn handle_event( &mut self, evt: &Event, hub: &Hub, bus: &mut Bus, rq: &mut RenderQueue, context: &mut Context, ) -> bool

Source§

fn render(&self, fb: &mut dyn Framebuffer, rect: Rectangle, fonts: &mut Fonts)

Source§

fn rect(&self) -> &Rectangle

Source§

fn rect_mut(&mut self) -> &mut Rectangle

Source§

fn children(&self) -> &Vec<Box<dyn View>>

Source§

fn children_mut(&mut self) -> &mut Vec<Box<dyn View>>

Source§

fn id(&self) -> Id

Source§

fn render_rect(&self, _rect: &Rectangle) -> Rectangle

Source§

fn resize( &mut self, rect: Rectangle, _hub: &Hub, _rq: &mut RenderQueue, _context: &mut Context, )

Source§

fn child(&self, index: usize) -> &dyn View

Source§

fn child_mut(&mut self, index: usize) -> &mut dyn View

Source§

fn len(&self) -> usize

Source§

fn might_skip(&self, _evt: &Event) -> bool

Source§

fn might_rotate(&self) -> bool

Source§

fn is_background(&self) -> bool

Source§

fn view_id(&self) -> Option<ViewId>

Auto Trait Implementations§

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. 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