Button

public class Button : View

Button is a view that provides an item that invokes a callback when activated.

Provides a button that can be clicked, or pressed with the enter key or space key. It also responds to hotkeys (the first letter after an underscore) and triggers the execution of a callback method.

If the button is configured as the default IsDefault the button will respond to the return key is no other view processes it, and turns this into a clicked event.

To connect a clicked handler, set the clicked property here to your callback

 var d = Dialog("_Hello")
 var ok = Button ("Ok")
 ok.clicked = { d.requestStop () }
 d.addButton (ok)
 Application.run (d)
  • When a button is the default, pressing return in the dialog will trigger this button if no other control consumes it

    Declaration

    Swift

    public var isDefault: Bool { get set }
  • The text displayed by the button. The first uppercase letter in the button becomes the hotkey

    Declaration

    Swift

    public var text: String { get set }
  • Assigning to this variable a method will invoke it when the button is clicked, alternatively, you can use clickedSubject for use with Combine

    Declaration

    Swift

    public var clicked: ((_ source: Button) -> ())?
  • Subject that is raised when the button has been activated, a more comprehensive version of the “clicked’ callback

    Declaration

    Swift

    public var clickedSubject: PassthroughSubject<View, Never>
  • Declaration

    Swift

    public override init()
  • Initializes a button with the text contained in the first parameter, the first uppercase letter by convention is the hotkey

    Declaration

    Swift

    public convenience init(_ text: String, clicked: (() -> ())? = nil)

    Parameters

    text

    Contains the text for the button. The first uppercase letter in the button becomes the hotkey

    clicked

    Optional method to invoke when the button is clicked

  • 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 processColdKey(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 }