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: boolImplementations§
Source§impl ToggleableKeyboard
impl ToggleableKeyboard
Sourcepub fn new(parent_rect: Rectangle, number_mode: bool) -> Self
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 positioningnumber_mode- Iftrue, the keyboard starts in number mode
§Returns
A new ToggleableKeyboard instance in hidden state.
Sourcepub fn toggle(&mut self, hub: &Hub, rq: &mut RenderQueue, context: &mut Context)
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 eventsrq- Render queue for scheduling redrawscontext- Application context for updating keyboard state
Sourcepub fn set_visible(
&mut self,
visible: bool,
hub: &Hub,
rq: &mut RenderQueue,
context: &mut Context,
)
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-trueto show the keyboard,falseto hide ithub- Event hub for sending focus eventsrq- Render queue for scheduling redrawscontext- Application context for updating keyboard state
Sourcepub fn set_number_mode(&mut self, number_mode: bool)
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-trueto enable number mode,falsefor letter mode
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Returns whether the keyboard is currently visible.
§Returns
true if the keyboard is visible, false otherwise.
Sourcefn show(&mut self, rq: &mut RenderQueue, context: &mut Context)
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.
Sourcefn hide(&mut self, hub: &Hub, rq: &mut RenderQueue, context: &mut Context)
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
impl View for ToggleableKeyboard
fn handle_event( &mut self, evt: &Event, hub: &Hub, bus: &mut Bus, rq: &mut RenderQueue, context: &mut Context, ) -> bool
fn render(&self, fb: &mut dyn Framebuffer, rect: Rectangle, fonts: &mut Fonts)
fn rect(&self) -> &Rectangle
fn rect_mut(&mut self) -> &mut Rectangle
fn children(&self) -> &Vec<Box<dyn View>>
fn children_mut(&mut self) -> &mut Vec<Box<dyn View>>
fn id(&self) -> Id
fn render_rect(&self, _rect: &Rectangle) -> Rectangle
fn resize( &mut self, rect: Rectangle, _hub: &Hub, _rq: &mut RenderQueue, _context: &mut Context, )
fn child(&self, index: usize) -> &dyn View
fn child_mut(&mut self, index: usize) -> &mut dyn View
fn len(&self) -> usize
fn might_skip(&self, _evt: &Event) -> bool
fn might_rotate(&self) -> bool
fn is_background(&self) -> bool
fn view_id(&self) -> Option<ViewId>
Auto Trait Implementations§
impl Freeze for ToggleableKeyboard
impl !RefUnwindSafe for ToggleableKeyboard
impl !Send for ToggleableKeyboard
impl !Sync for ToggleableKeyboard
impl Unpin for ToggleableKeyboard
impl !UnwindSafe for ToggleableKeyboard
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.