]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/ui/gadgets/comboboxes/comboboxes.factor
a2a7585254c49d4c83ce9e9c8e3dc7e1d89598f4
[factor.git] / unmaintained / ui / gadgets / comboboxes / comboboxes.factor
1 USING: accessors arrays kernel math.rectangles sequences
2 ui.gadgets.controls models.combinators ui.gadgets ui.gadgets.glass
3 ui.gadgets.labels ui.gestures ;
4 QUALIFIED-WITH: ui.gadgets.tables tbl
5 IN: ui.gadgets.comboboxes
6
7 TUPLE: combo-table < table spawner ;
8
9 M: combo-table handle-gesture [ call-next-method drop ] 2keep swap
10    T{ button-up } = [
11       [ spawner>> ]
12       [ tbl:selected-row [ swap set-control-value ] [ 2drop ] if ]
13       [ hide-glass ] tri
14    ] [ drop ] if t ;
15
16 TUPLE: combobox < label-control table ;
17 combobox H{
18    { T{ button-down } [ dup table>> over >>spawner <zero-rect> show-glass ] }
19 } set-gestures
20
21 : <combobox> ( options -- combobox ) [ first [ combobox new-label ] keep <basic> >>model ] keep
22     <basic> combo-table new-table [ 1array ] >>quot >>table ;