Skip to content

UI.Button

Name Mandatory Description Default Type
⬅️ Input The value that will be passed to the Action shards of the button. Any
Output ➡️ Indicates whether the button was clicked during this frame. Bool
Label No The text label of this button. `` StringVar(String)
Action No The shards to execute when the button is pressed. none NoneShard[Shard]
Style No The text style. none {Any}Var({Any})None
Wrap No The text wrapping mode. TextWrap::Extend TextWrapBool
Selected No Indicates whether the button is selected. none BoolVar(Bool)None

Clickable button with text.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
// Simple button
GFX.MainWindow(Contents: {
  // Setup
  GFX.DrawQueue = ui-draw-queue
  GFX.UIPass(ui-draw-queue) >> render-steps

  // UI
  UI({
    UI.CentralPanel({
      UI.Button(Label: "Click me!" Action: {
        Msg("Clicked")
      })
    })
  })

  UI.Render(ui-draw-queue)

  GFX.Render(Steps: render-steps)
})

[warning] Context has 2 buffers at release (2 released, 2 kept)
[warning] Context has 5 textures at release (1 released, 5 kept)
 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Styled button
GFX.MainWindow(Contents: {
  // Setup
  GFX.DrawQueue = ui-draw-queue
  GFX.UIPass(ui-draw-queue) >> render-steps

  // UI
  UI({
    UI.CentralPanel({
      UI.Button(
        Label: "Click me!"
        Style: {color: @color(255 255 0)}
        Action: {
          Msg("Clicked")
        }
      )
    })
  })

  UI.Render(ui-draw-queue)

  GFX.Render(Steps: render-steps)
})

[warning] Context has 2 buffers at release (2 released, 2 kept)
[warning] Context has 5 textures at release (1 released, 5 kept)