Trait kas::WidgetCore[][src]

pub trait WidgetCore: Any + Debug {
    fn as_any(&self) -> &(dyn Any + 'static);
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static);
fn core_data(&self) -> &CoreData;
fn widget_name(&self) -> &'static str;
fn as_widget(&self) -> &(dyn WidgetConfig + 'static);
fn as_widget_mut(&mut self) -> &mut (dyn WidgetConfig + 'static); fn id(&self) -> WidgetId { ... }
fn is_disabled(&self) -> bool { ... }
fn set_disabled(&mut self, disabled: bool) -> TkAction { ... }
fn with_disabled(self, disabled: bool) -> Self { ... }
fn rect(&self) -> Rect { ... }
fn input_state(&self, mgr: &ManagerState, disabled: bool) -> InputState { ... } }
Expand description

Base widget functionality

See the Widget trait for documentation of the widget family.

This trait must be implement by the derive(Widget) macro. Users must not implement this WidgetCore trait manually or may face unexpected breaking changes.

Required methods

Get self as type Any

Get self as type Any (mutable)

Get direct access to the CoreData providing property storage.

Get the name of the widget struct

Erase type

Erase type

Provided methods

Get the widget’s numeric identifier

Get whether the widget is disabled

Set the disabled state of a widget

If disabled, a widget should not respond to input and should appear greyed out.

The disabled status is inherited by children: events should not be passed to them, and they should also be drawn greyed out.

Set disabled state (chaining)

This is identical to WidgetCore::set_disabled, but can be called in chaining fashion. Example:

use kas::{WidgetCore, widget::MenuEntry};
let entry = MenuEntry::new("Disabled Item", ()).with_disabled(true);

Get the widget’s region, relative to its parent.

Construct InputState

The disabled flag is inherited from parents. InputState::disabled will be true if either disabled or self.is_disabled() are true.

The error state defaults to false since most widgets don’t support this.

Note: most state changes should automatically cause a redraw, but change in hover status will not (since this happens frequently and many widgets are unaffected), unless WidgetConfig::hover_highlight returns true.

Implementations

Forwards to the method defined on the type Any.

Forwards to the method defined on the type Any.

Forwards to the method defined on the type Any.

Implementations on Foreign Types

Implementors