[][src]Trait kas::Widget

pub trait Widget: Layout {
    fn configure(&mut self, _: &mut Manager) { ... }
fn update_timer(&mut self, _: &mut Manager) -> Option<Duration> { ... }
fn update_handle(&mut self, _: &mut Manager, _: UpdateHandle) { ... }
fn allow_focus(&self) -> bool { ... } }

A widget is a UI element.

Widgets usually occupy space within the UI and are drawable. Widgets may respond to user events. Widgets may have child widgets.

Widgets must implement the child trait WidgetCore and the Handler trait, besides this trait. It is recommended to use the derive(Widget) macro to generate some of the required implementations. See documentation in the kas::macros module.

Example of a simple widget which draws a frame around its child:

use kas::macros::Widget;
use kas::{CoreData, LayoutData, Widget};

#[widget]
#[layout(single, frame)]
#[derive(Clone, Debug, Widget)]
pub struct Frame<W: Widget> {
    #[core] core: CoreData,
    #[layout_data] layout_data: <Self as LayoutData>::Data,
    #[widget] child: W,
}

Provided methods

fn configure(&mut self, _: &mut Manager)

Configure widget

Widgets are configured on window creation and when kas::TkAction::Reconfigure is sent.

This method is called immediately after assigning self.core_data().id.

fn update_timer(&mut self, _: &mut Manager) -> Option<Duration>

Update the widget via a timer

This method is called on scheduled updates (see update_on_timer).

When some Duration is returned, another timed update is scheduled at approximately this duration from now (but without blocking redraws; usage of 1ns effectively enables per-frame update with FPS limited via VSync). Required: duration > 0.

This method being called does not imply a redraw.

fn update_handle(&mut self, _: &mut Manager, _: UpdateHandle)

Update the widget via an update handle

This method is called on triggered updates (see update_on_handle). The source handle is specified via the UpdateHandle parameter.

This method being called does not imply a redraw.

fn allow_focus(&self) -> bool

Is this widget navigable via Tab key?

Loading content...

Implementations on Foreign Types

impl<M> Widget for Box<dyn Handler<Msg = M>>[src]

Loading content...

Implementors

impl Widget for Label[src]

impl Widget for MessageBox[src]

impl<D: Direction> Widget for ScrollBar<D>[src]

impl<D: Direction, W: Widget> Widget for List<D, W>[src]

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

impl<M: Clone + Debug> Widget for TextButton<M>[src]

impl<OT: 'static> Widget for CheckBox<OT>[src]

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

impl<W: Widget> Widget for ScrollRegion<W>[src]

Loading content...