[][src]Trait kas::Widget

pub trait Widget: Layout {
    fn class(&self) -> Class;
fn len(&self) -> usize;
fn get(&self, index: usize) -> Option<&dyn Widget>;
fn get_mut(&mut self, index: usize) -> Option<&mut dyn 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

Loading content...

Implementors

impl Widget for Text
[src]

impl<H: 'static> Widget for TextButton<H>
[src]

impl<H: 'static> Widget for Entry<H>
[src]

impl<M: Debug + 'static, H: 'static> Widget for MessageBox<M, H>
[src]

impl<W: Widget + 'static> Widget for SimpleWindow<W>
[src]

Loading content...