Skip to content

UI.ListBox

Name - Description Default Type
<input> A sequence of values. Any
<output> The selected value. Any
Index The index of the selected item. none IntVar(Int)
IsSelected Predicate that should return selection state of an item, receives the index in the list, should return true/false. none Shard[Shard]
Clicked Action to perform if an element of the list is being clicked. none Shard[Shard]
Template Custom rendering none Shard[Shard]

A list selection.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
(GFX.MainWindow
 :Contents
 (->
  (Setup
   (GFX.DrawQueue) >= .ui-draw-queue
   (GFX.UIPass .ui-draw-queue) >> .render-steps)
  (UI
   (UI.CentralPanel
    (->
     ["α Α" "ω Ω"]
     (UI.ListBox :Index .index)
     (ExpectString) >= .value

     (UI.Horizontal
      (-> "Selected index: " (UI.Label)
          .index (ToString) (UI.Label))))))

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

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
(GFX.MainWindow
 :Contents
 (->
  (Setup
   (GFX.DrawQueue) >= .ui-draw-queue
   (GFX.UIPass .ui-draw-queue) >> .render-steps)
  (UI
   (UI.CentralPanel
    (->
     [1 2 3 4 5 6 7 8 9]
     (UI.ListBox
      :Index .index
      :Template
      (->
       (ToString) (UI.Label)))
     (ExpectInt) >= .value

     (UI.Horizontal
      (-> "Selected index: " (UI.Label)
          .index (ToString) (UI.Label))))))

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

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(GFX.MainWindow
 :Contents
 (->
  (Setup
   (GFX.DrawQueue) >= .ui-draw-queue
   (GFX.UIPass .ui-draw-queue) >> .render-steps)

  (UI
   (UI.CentralPanel
    (->

     (Setup
      -1 >= .clicked
      [1 2 3 4 5 6 7 8 9] = .items)

     .items
     (UI.ListBox
      :IsSelected (->
                   = .i
                   .clicked (If (IsLess 0) (-> false)
                                (-> (IsLessEqual .i))))
      :Clicked (-> > .clicked)
      :Template
      (->
       (ToString) (UI.Label)))
     (ExpectInt) >= .value

     (UI.Horizontal
      (-> "Selected index: " (UI.Label)
          .clicked (ToString) (UI.Label))))))

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