Button
classin packageklyn.gui.terminal
public class Button extends Widget:
└ Widget
└ Button

Clickable terminal button with the standard Klyn terminal style.

The default background matches the terminal menu bar. Screens that need a semantic variant, such as destructive Delete buttons, should override the color properties on the instance instead of redefining the generic default.

saveButton = Button("Save")
saveButton.clicked += lambda(event: ActionEvent): print("saved")
saveButton.centered = true
saveButton.size = (20u, UInt(Button.DEFAULT_HEIGHT))
Fields
Modifier and Type Member Description
public static const DEFAULT_BG_FOCUS
DEFAULT_BG_FOCUS as String = "\u001b[48;2;0;200;255m"
No summary.
public static const DEFAULT_BG_NORMAL
DEFAULT_BG_NORMAL as String = "\u001b[48;2;0;120;160m"
No summary.
public static const DEFAULT_FG_FOCUS
DEFAULT_FG_FOCUS as String = "\u001b[38;2;255;255;255m"
No summary.
public static const DEFAULT_FG_NORMAL
DEFAULT_FG_NORMAL as String = "\u001b[38;2;255;255;255m"
No summary.
public static const DEFAULT_HEIGHT
DEFAULT_HEIGHT as Int = 3
No summary.
public static const DEFAULT_HORIZONTAL_PADDING
DEFAULT_HORIZONTAL_PADDING as Int = 3
No summary.
public static const DEFAULT_VERTICAL_PADDING
DEFAULT_VERTICAL_PADDING as Int = 1
No summary.
Inherited Attributes
attributeInherited Attributes from Widget: lastRenderAnsi, lastRenderHeight, lastRenderPlain, lastRenderWidth, layout, visible
Properties
Modifier and Type Member Description
public property bgFocus
bgFocus as String = Button.DEFAULT_BG_FOCUS
No summary.
public property bgNormal
bgNormal as String = Button.DEFAULT_BG_NORMAL
No summary.
public property centered
centered as Boolean = false
No summary.
public property fgFocus
fgFocus as String = Button.DEFAULT_FG_FOCUS
No summary.
public property fgNormal
fgNormal as String = Button.DEFAULT_FG_NORMAL
No summary.
public override readonly property focusable
focusable as Boolean = true
No summary.
public override property focused
focused as Boolean:
No summary.
public property horizontalPadding
horizontalPadding as Int = Button.DEFAULT_HORIZONTAL_PADDING
No summary.
public property hovered
hovered as Boolean = false
No summary.
public property id
id as String = ""
No summary.
public property label
label as String = ""
No summary.
public property verticalPadding
verticalPadding as Int = Button.DEFAULT_VERTICAL_PADDING
No summary.
Inherited Properties
propertyInherited Properties from Widget: focusable, focused, lastRenderFrame, position, size
propertyInherited Properties from Object: type
Events
Modifier and Type Member Description
public event clicked
clicked as ActionEvent
Rich action event emitted when the terminal button is activated.
Constructors
Modifier and Type Member Description
public Button
Button(label as String = ""):
No summary.
Methods
Modifier and Type Member Description
public static focusRenderStyle
focusRenderStyle() as RenderStyle:
Returns the standard visual style for a focused or hovered button.
public override handleEvent
handleEvent(eventName as String) as Boolean:
No summary.
public override handleMouseEvent
handleMouseEvent(mouse as MouseEvent, localX as Int, localY as Int, viewWidth as Int, viewHeight as Int) as Boolean:
No summary.
public static normalRenderStyle
normalRenderStyle() as RenderStyle:
Returns the standard visual style for an idle button.
public override paintToFrame
paintToFrame(frame as TerminalFrame, row as Int, col as Int, width as Int, height as Int) as Boolean:
No summary.
Inherited Methods
methodInherited Methods from Widget: add, baseAnsiStyle, captureRenderFrame, children, clearChildren, configureCursor, focusNext, handleEvent, handleMouseEvent, hasActiveTextInput, idle, paint, paintToFrame, performLayout, refresh, renderAnsiSnapshot, renderPlainSnapshot, scrollbarThumbGlyph, scrollbarTrackGlyph, terminalPromptVisible
methodInherited Methods from Object: deepCopy, fromJson, toDict, toJson, toString, toXml