Forward declaration for Widget (defined in widget.cr)
Class methods
handling_capture=(handling_capture :
Bool)
Flag to prevent re-redirect when processing captured widget's children
Sourcehandling_capture?
Flag to prevent re-redirect when processing captured widget's children
SourceInstance methods
apply_css_style(style :
Hash(
String,
CSS::Value)) :
Nil Apply CSS style properties to this widget
Override in subclasses to handle specific properties
Sourcecapture_mouse
Capture all mouse events (for dragging)
Sourceconstraints
Layout constraints (CSS-driven)
Sourceconstraints=(constraints : Constraints)
Layout constraints (CSS-driven)
Sourcefocus
Request focus (convenience method)
Sourcefocus!
Alias for focus (bang version for Button etc.)
Sourcehandle_event(event :
Event) :
Bool KISS event handling with capture support
Flow: on_capture → children → on_event
Override on_capture to intercept before children
Override on_event to handle after children
Sourcemargin=(margin : BoxModel)
SourceCheck if widget matches a simple selector
Sourceoffset_x
Offset (shifts widget from calculated position)
Sourceoffset_x=(offset_x :
Int32)
Offset (shifts widget from calculated position)
Sourceon_capture(event :
Event) :
Bool Override to intercept events BEFORE they reach children (capture phase)
Return true to stop propagation to children
Use for: global hotkeys, modal dialogs, event filtering
Sourceon_event(event :
Event) :
Bool Override to handle events for this widget (target/bubble phase)
Called after children have had a chance to handle the event
Sourceon_key(event :
KeyEvent) :
Bool Handle key event specifically (convenience method)
Sourceon_mount
Called when widget is added to tree
Sourceon_mouse(event :
MouseEvent) :
Bool Handle mouse event specifically (convenience method)
Sourceon_unmount
Called when widget is removed from tree
Sourceopacity
Opacity (0.0 = transparent, 1.0 = opaque)
SourceOpacity (0.0 = transparent, 1.0 = opaque)
Sourcepadding=(padding : BoxModel)
Sourcequery_one(selector :
String, type :
T.class) :
T |
Nil forall
T Find single widget by selector and type
Sourcerect
Geometry (set by layout engine)
Sourcerect=(rect : Rect)
Geometry (set by layout engine)
Sourcerender(buffer : Buffer, clip : Rect) : Nil
Override to render widget content
Sourcerender_rect
Returns the rect needed for rendering (may be larger than layout rect)
Override for widgets like dropdowns that render outside their bounds
Sourcerequest_render
Request re-render (to be implemented by Widget)
Sourcez_index
Z-order (higher = on top)
Sourcez_index=(z_index :
Int32)
Z-order (higher = on top)
Source