Trait kas::WidgetConfig[][src]

pub trait WidgetConfig: Layout {
    fn configure(&mut self, &mut Manager<'_>) { ... }
fn configure_recurse(&mut self, cmgr: ConfigureManager<'_, '_>) { ... }
fn key_nav(&self) -> bool { ... }
fn hover_highlight(&self) -> bool { ... }
fn cursor_icon(&self) -> CursorIcon { ... } }
Expand description

Widget configuration

This trait is part of the Widget family and is derived by derive(Widget) unless #[widget(config = noauto)] is used. key_nav and cursor_icon may be customised without a manual implementation (e.g. #[widget(config(key_nav = true))]).

This trait allows some configuration of widget behaviour. All methods have default implementations. Most frequently, this trait is used to implement some custom action during configure: WidgetConfig::configure.

Provided methods

Configure widget

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

Configure is called before resizing (but after calculation of the initial window size). This method is called after a WidgetId has been assigned to self, and after configure has been called on each child.

It is not advised to perform any action requiring a reconfigure (e.g. adding a child widget) during configure due to the possibility of getting stuck in a reconfigure-loop. See issue kas#91 for more on this. KAS has a crude mechanism to detect this and panic.

The default implementation of this method does nothing.

Configure self and children

In most cases one should not override the default implementation of this method but instead use WidgetConfig::configure; the exception is widgets with pop-ups.

Is this widget navigable via Tab key?

Defaults to false.

Does this widget have hover-state highlighting?

If true, a redraw will be requested whenever this widget gains or loses mouse-hover status.

Which cursor icon should be used on hover?

Defaults to event::CursorIcon::Default.

Implementations on Foreign Types

Implementors