Checkbox

public class Checkbox : View

The Checkbox View shows an on/off toggle that the user can set

Example:

 c = Checkbox ("Toggle me")
 c.x = Pos.at (0)
 c.y = Pos.at (0)
 c.width = Dim(30)
 c.height = Dim (1)
 c.toggled = { check in ... }

 // Alternatively, you can use Combine to track the event changes:
 var cancellable = c.toggledSubject.sink { cbox in }

  • The state of the checkbox.

    Declaration

    Swift

    public var checked: Bool { get set }
  • Subject that is raised when the checkbox has been toggled, a more comprehensive version of the “toggled’ callback

    Declaration

    Swift

    public var toggledSubject: PassthroughSubject<Checkbox, Never>
  • Callback to invoke when the checkbox has been toggled, this allows a single callback to be registered. For more complex scenarios, use toggledSubject which is a Combine subject.

    Declaration

    Swift

    public var toggled: ((_ sender: Checkbox) -> ())?
  • Used to override the hotkey to use for this checkbox

    Declaration

    Swift

    public var hotKey: Character? { get set }
  • Sets the text for the checkbox, and will automatically pick the HotKey as the first uppercased letter in the string. This can be later overwritten by setting HotKey directly.

    Declaration

    Swift

    public var text: String { get set }
  • Undocumented

    Declaration

    Swift

    public init(_ text: String, checked: Bool = false)
  • Declaration

    Swift

    public override func redraw(region: Rect, painter: Painter)
  • Declaration

    Swift

    public override func positionCursor()
  • Declaration

    Swift

    public override func processHotKey(event: KeyEvent) -> Bool
  • Declaration

    Swift

    public override func processKey(event: KeyEvent) -> Bool
  • Declaration

    Swift

    public override func mouseEvent(event: MouseEvent) -> Bool
  • Undocumented

    Declaration

    Swift

    public override var debugDescription: String { get }