]> gitweb.factorcode.org Git - factor.git/blob - core/ui/gadgets/controls.facts
fed8c7a39a558ceeb9f8fd2cff9d4089b859a99b
[factor.git] / core / ui / gadgets / controls.facts
1 IN: gadgets
2 USING: help gadgets-buttons gadgets-panes gadgets-labels
3 generic models kernel ;
4
5 HELP: control
6 { $class-description "A control is a " { $link gadget } " linked with a " { $link model } " stored in the " { $link control-model } " slot. Changes to the model are reflected in the appearance and behavior of the control, and the control may in turn change the value of the model in response to user input."
7 $terpri
8 "Controls are created by calling " { $link <control> } " and " { $link delegate>control } ". Other words to create controls include:"
9 { $list
10     { $link <label-control> }
11     { $link <radio-control> }
12     { $link <pane-control> }
13 }
14 $terpri
15 "Objects may delegate to " { $link control } " instances, in which case the " { $link control-self } " slot must be set to the frontmost object in the delegation chain. This ensures that the correct object receives notification of model changes." }
16 { $see-also control-value set-control-value } ;
17
18 HELP: <control>
19 { $values { "model" model } { "gadget" gadget } { "quot" "a quotation with stack effect " { $snippet "( value control -- )" } } }
20 { $description "Creates a new control linked to the given model. The gadget parameter becomes the control's delegate. The quotation is called when the model value changes," }
21 { $see-also delegate>control control-value set-control-value } ;
22
23 HELP: control-value
24 { $values { "control" control } { "value" object } }
25 { $description "Outputs the value of the control's model." } ;
26
27 HELP: set-control-value
28 { $values { "value" object } { "control" control } }
29 { $description "Sets the value of the control's model." } ;
30
31 HELP: delegate>control
32 { $values { "tuple" tuple } { "model" model } { "underlying" gadget } }
33 { $description "Creates a new " { $link control } " and creates a delegation chain where " { $snippet "tuple" } " at the front delegates to the new " { $link control } " which delegates to " { $snippet "underlying" } ". The " { $link model-changed } " word is called on " { $snippet "tuple" } " when the model changes." }
34 { $side-effects "tuple" }
35 { $see-also <control> } ;