class

Opal::UI::Switch

Inherits Opal::UI::Control < Opal::UI::InputHookable < Opal::UI::Element < Opal::UI::Themable < Reference < Object

Interactive toggle switch widget inspired by Python Textual's Switch. Features smooth pill-track rendering, keyboard (Space/Enter) toggle, mouse click hit-testing, customizable ON/OFF glyphs and colors, and change callbacks.

Constructors

new(label : String | Nil = nil, on : Bool = false, disabled : Bool = false, on_change : Proc(Bool, Nil) | Nil = nil)
Source
new(label : String | Nil = nil, on : Bool = false, disabled : Bool = false, &block : Bool -> Nil) : Switch
Source

Instance methods

disabled=(disabled : Bool)
Source
disabled?
Source
focus_border_fg
Source
focus_border_fg=(focus_border_fg : Color | Nil)
Source
handle_key(event : Terminal::KeyEvent) : Bool

Default key event handler. Override in subclasses if not using @default_input_proc.

Source
handle_mouse(event : Terminal::MouseEvent) : Bool

Default mouse event handler. Override in subclasses if not using @default_input_proc.

Source
label
Source
label=(label : String | Nil)
Source
label_fg
Source
label_fg=(label_fg : Color | Nil)
Source
off_thumb_bg
Source
off_thumb_bg=(off_thumb_bg : Color | Nil)
Source
off_thumb_fg
Source
off_thumb_fg=(off_thumb_fg : Color | Nil)
Source
off_track_bg
Source
off_track_bg=(off_track_bg : Color | Nil)
Source
off_track_fg
Source
off_track_fg=(off_track_fg : Color | Nil)
Source
on=(val : Bool)
Source
on_change
Source
on_change
Source
on_change=(on_change : Proc(Bool, Nil) | Nil)
Source
on_thumb_bg
Source
on_thumb_bg=(on_thumb_bg : Color | Nil)
Source
on_thumb_fg

Manipulable theme properties and glyph swaps

Source
on_thumb_fg=(on_thumb_fg : Color | Nil)

Manipulable theme properties and glyph swaps

Source
on_track_bg
Source
on_track_bg=(on_track_bg : Color | Nil)
Source
on_track_fg
Source
on_track_fg=(on_track_fg : Color | Nil)
Source
preferred_size(available_w : Int32, available_h : Int32) : Tuple(Int32, Int32)
Source
render(buffer : Buffer, x : Int32, y : Int32, width : Int32, height : Int32) : Nil
Source
thumb_char
Source
thumb_char=(thumb_char : Char | Nil)
Source
toggle

Toggles state if not disabled

Source
track_char
Source
track_char=(track_char : Char | Nil)
Source