Widget
class in package klyn.gui.windows

    public abstract class Widget:

Widget

Base class for the window widgets.

The layout system stores all computed geometry directly on widgets so the native backend can consume the same contract later.

    label = Label("Hello")
    label.margin = (8, 4, 8, 4)
    label.setBounds(10, 20, 120, 26)

Properties

Modifier and Type | Member | Description
--- | --- | ---
public property | accentColor `accentColor as Color` | Accent color used by focused and primary controls.
public property | backgroundColor `backgroundColor as Color` | Background color used by filled controls.
public property | borderColor `borderColor as Color` | Border color used by framed controls.
public readonly property | bottom `bottom as Int:` | Bottom edge of the widget.
public property | canFocus `canFocus as Boolean` | Whether the widget can own keyboard focus.
public property | cornerRadius `cornerRadius as Int` | Default corner radius for rounded controls.
public property | cursor `cursor as String` | Mouse cursor displayed while the pointer is over this widget.
public property | font `font as String` | Default font used to render this widget.
public property | foregroundColor `foregroundColor as Color` | Main text and icon color.
public property | hasFocus `hasFocus as Boolean` | Focus flag maintained by the GUI backend.
public property | height `height as Int` | Computed height.
public property | isEnabled `isEnabled as Boolean` | Enabled flag.
public property | isHovered `isHovered as Boolean` | Hover flag maintained by the GUI backend.
public property | isManaged `isManaged as Boolean` | When false, layout managers ignore this widget.
public property | isTabStop `isTabStop as Boolean` | Whether Tab/Shift+Tab navigation should stop on this widget.
public property | isVisible `isVisible as Boolean` | Visibility flag.
public property | layoutParams `layoutParams as Object = null` | Optional layout-specific metadata.
public property | margin `margin as IList<Int>` | Outer margins expressed as `(left, top, right, bottom)`.
public property | maxHeight `maxHeight as Int` | Maximal allowed height.
public property | maxWidth `maxWidth as Int` | Maximal allowed width.
public property | minHeight `minHeight as Int` | Minimal allowed height.
public property | minWidth `minWidth as Int` | Minimal allowed width.
public property | parent `parent as Container` | Parent container of this widget.
public property | preferredHeight `preferredHeight as Int` | Preferred height used by layout managers.
public property | preferredWidth `preferredWidth as Int` | Preferred width used by layout managers.
public property | resolvedStyleCache `resolvedStyleCache as Object = null` | Internal resolved KSS style cache used by `ThemeManager`.
public property | resolvedStyleCacheAppearanceMode `resolvedStyleCacheAppearanceMode as String = ""` | Internal appearance mode associated with `resolvedStyleCache`.
public property | resolvedStyleCacheFont `resolvedStyleCacheFont as String = ""` | Internal font key associated with `resolvedStyleCache`.
public property | resolvedStyleCacheRevision `resolvedStyleCacheRevision as Int = -1` | Internal KSS theme revision associated with `resolvedStyleCache`.
public property | resolvedStyleCacheStateKey `resolvedStyleCacheStateKey as Int = -1` | Internal widget state key associated with `resolvedStyleCache`.
public property | resolvedStyleCacheStyleClass `resolvedStyleCacheStyleClass as String = ""` | Internal KSS class key associated with `resolvedStyleCache`.
public property | resolvedStyleCacheZoomRevision `resolvedStyleCacheZoomRevision as Int = -1` | Internal content zoom revision associated with `resolvedStyleCache`.
public readonly property | right `right as Int:` | Right edge of the widget.
public property | size `size as Tuple<Int, Int>:` | Computed widget dimensions expressed as `(width, height)`.
public property | sizePolicy `sizePolicy as Tuple<SizePolicy, SizePolicy>` | Layout growth policy expressed as `(horizontal, vertical)`.
public property | styleClass `styleClass as String` | Optional KSS class name.
public property | toolTip `toolTip as String` | Optional text displayed in a floating tooltip while the pointer hovers over this widget.
public property | width `width as Int` | Computed width.
public property | window `window as Window` | Owning window, propagated when the widget is inserted in a window tree.
public property | x `x as Int` | Computed left position.
public propert | y `y y as Int` | Computed top position.

Events

Modifier and Type | Member | Description
--- | --- | ---
public event | keyPressed `keyPressed as KeyEvent` | Keyboard press event emitted when this widget has focus.
public event | keyReleased `keyReleased as KeyEvent` | Keyboard release event emitted when this widget has focus.
public event | mouseMoved `mouseMoved as MouseEvent` | Mouse move event emitted while the pointer is over this widget.
public event | mousePressed `mousePressed as MouseEvent` | Mouse button press event emitted for this widget.
public event | mouseReleased `mouseReleased as MouseEvent` | Mouse button release event emitted for this widget.
public event | mouseWheel `mouseWheel as MouseWheelEvent` | Mouse wheel event emitted while the pointer is over this widget.
public event | paintRequested `paintRequested as PaintEvent` | Paint request event emitted by `notifyPaintRequested`.
public event | resized `resized as ResizeEvent` | Resize event emitted when this widget's computed size changes.

Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | Widget `Widget():` | No summary.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | blur `blur() as Void:` | Clears keyboard focus on this widget.
public | containsPoint `containsPoint(x as Int, y as Int) as Boolean:` | Returns true when a point is inside this widget bounds.
public | emitKeyPressed `emitKeyPressed(key as String, keyCode as Int, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void:` | Native backend hook for key press dispatch.
public | emitKeyReleased `emitKeyReleased(key as String, keyCode as Int, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void:` | Native backend hook for key release dispatch.
public | emitMouseMoved `emitMouseMoved(x as Int, y as Int, button as Int = 0, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void:` | Native backend hook for mouse move dispatch.
public | emitMousePressed `emitMousePressed(x as Int, y as Int, button as Int = 1, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void:` | Native backend hook for mouse press dispatch.
public | emitMouseReleased `emitMouseReleased(x as Int, y as Int, button as Int = 1, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void:` | Native backend hook for mouse release dispatch.
public | emitMouseWheel `emitMouseWheel(x as Int, y as Int, deltaX as Int = 0, deltaY as Int = 0, alt as Boolean = false, control as Boolean = false, shift as Boolean = false) as Void:` | Native backend hook for mouse wheel dispatch.
public | handleTabKey `handleTabKey(backward as Boolean) as Boolean:` | Gives a focused widget a chance to consume Tab before focus navigation.
public | notifyPaintRequested `notifyPaintRequested(painter as Painter) as Void:` | Emits `paintRequested` for the current widget bounds.
public | paint `paint(painter as Painter) as Void:` | Paint hook used by the future graphical backend.
public | paintClipped `paintClipped(painter as Painter) as Void:` | Paints this widget clipped to its computed bounds.
public | paintOverlay `paintOverlay(painter as Painter) as Void:` | Paints visual elements that must appear above the normal widget tree.
public | repaint `repaint() as Void:` | Requests a repaint of the owning window without changing layout.
public | requestFocus `requestFocus() as Boolean:` | Requests keyboard focus for this widget.
public | resolvePreferredHeight `resolvePreferredHeight() as Int:` | Resolved preferred height after min/max constraints.
public | resolvePreferredWidth `resolvePreferredWidth() as Int:` | Resolved preferred width after min/max constraints.
public | resolvedFont `resolvedFont() as String:` | Returns the effective font description used by painter-based renderers.
public | setBounds `setBounds(x as Int, y as Int, width as Int, height as Int) as Void:` | Updates the computed widget bounds.