[−][src]Trait kas::Widget
A widget encapsulates code for event handling and/or drawing some feature of a sub-region of a window.
Widgets must usually also implement the Handler
trait, which is separate
since it is generic.
This trait should only be implemented by using the derive(Widget)
macro,
which can optionally also implement Handler
, as in the following example:
#![feature(unrestricted_attribute_tokens)] use kas::{Class, Widget, CoreData}; use kas::event::NoResponse; use kas::macros::Widget; #[widget(class = Class::Frame)] #[handler(response = NoResponse)] #[derive(Clone, Debug, Widget)] pub struct Frame<W: Widget> { #[core] core: CoreData, child: W, }
Required methods
fn class(&self) -> Class
Get the widget's classification
This includes access to additional class-specific interfaces.
fn len(&self) -> usize
Get the number of child widgets
fn get(&self, index: usize) -> Option<&dyn Widget>
Get a reference to a child widget by index, or None
if the index is
out of bounds.
For convenience, Index<usize>
is implemented via this method.
Required: index < self.len()
.
fn get_mut(&mut self, index: usize) -> Option<&mut dyn Widget>
Mutable variant of get
Implementors
impl Widget for Text
[src]
impl Widget for Text
fn class(&self) -> Class | [src] |
fn len(&self) -> usize | [src] |
fn get(&self, _index: usize) -> Option<&dyn Widget> | [src] |
fn get_mut(&mut self, _index: usize) -> Option<&mut dyn Widget> | [src] |
impl<H: 'static> Widget for TextButton<H>
[src]
impl<H: 'static> Widget for TextButton<H>
fn class(&self) -> Class | [src] |
fn len(&self) -> usize | [src] |
fn get(&self, _index: usize) -> Option<&dyn Widget> | [src] |
fn get_mut(&mut self, _index: usize) -> Option<&mut dyn Widget> | [src] |
impl<H: 'static> Widget for Entry<H>
[src]
impl<H: 'static> Widget for Entry<H>
fn class(&self) -> Class | [src] |
fn len(&self) -> usize | [src] |
fn get(&self, _index: usize) -> Option<&dyn Widget> | [src] |
fn get_mut(&mut self, _index: usize) -> Option<&mut dyn Widget> | [src] |
impl<M: Debug + 'static, H: 'static> Widget for MessageBox<M, H>
[src]
impl<M: Debug + 'static, H: 'static> Widget for MessageBox<M, H>
fn class(&self) -> Class | [src] |
fn len(&self) -> usize | [src] |
fn get(&self, _index: usize) -> Option<&dyn Widget> | [src] |
fn get_mut(&mut self, _index: usize) -> Option<&mut dyn Widget> | [src] |
impl<W: Widget + 'static> Widget for SimpleWindow<W>
[src]
impl<W: Widget + 'static> Widget for SimpleWindow<W>