[][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,
        _mgr: &mut Manager,
        _handle: UpdateHandle,
        _payload: u64
    ) { ... }
fn allow_focus(&self) -> bool { ... }
fn cursor_icon(&self) -> CursorIcon { ... } }

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 additionally implement the traits WidgetCore, Layout and Handler. The derive(Widget) macro may be used to generate some of these implementations.

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,
    _mgr: &mut Manager,
    _handle: UpdateHandle,
    _payload: u64
)

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.

A user-defined payload is passed. Interpretation of this payload is user-defined and unfortunately not type safe.

This method being called does not imply a redraw.

fn allow_focus(&self) -> bool

Is this widget navigable via Tab key?

fn cursor_icon(&self) -> CursorIcon

Which cursor icon should be used on hover?

Where no specific icon should be used, return CursorIcon::Default.

Loading content...

Implementations on Foreign Types

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

Loading content...

Implementors

impl Widget for Filler[src]

impl Widget for Label[src]

impl Widget for MessageBox[src]

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

impl<D: Directional, 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<OT: 'static> Widget for CheckBoxBare<OT>[src]

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

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

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

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

Loading content...