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
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Get self as type Any
(mutable)
fn widget_name(&self) -> &'static str
fn widget_name(&self) -> &'static str
Get the name of the widget struct
fn as_widget(&self) -> &(dyn WidgetConfig + 'static)
fn as_widget(&self) -> &(dyn WidgetConfig + 'static)
Erase type
fn as_widget_mut(&mut self) -> &mut (dyn WidgetConfig + 'static)
fn as_widget_mut(&mut self) -> &mut (dyn WidgetConfig + 'static)
Erase type
Provided methods
fn is_disabled(&self) -> bool
fn is_disabled(&self) -> bool
Get whether the widget is disabled
fn set_disabled(&mut self, disabled: bool) -> TkAction
fn set_disabled(&mut self, disabled: bool) -> TkAction
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.
fn with_disabled(self, disabled: bool) -> Self
fn with_disabled(self, disabled: bool) -> Self
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);
fn input_state(&self, mgr: &ManagerState, disabled: bool) -> InputState
fn input_state(&self, mgr: &ManagerState, disabled: bool) -> InputState
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
.