]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/gadgets/buttons/buttons-docs.factor
c4edaac144c6a1e463bf6ff302c1a0ceb34797f9
[factor.git] / basis / ui / gadgets / buttons / buttons-docs.factor
1 USING: help.markup help.syntax ui.gadgets ui.gadgets.labels
2 ui.render kernel models classes ;
3 IN: ui.gadgets.buttons
4
5 HELP: button
6 { $class-description "A button is a " { $link gadget } " which responds to mouse clicks by invoking a quotation."
7 $nl
8 "A button's appearance can vary depending on the state of the mouse button if the " { $snippet "interior" } " or " { $snippet "boundary" } " slots are set to instances of " { $link button-paint } "."
9 $nl
10 "A button can be selected, which is distinct from being pressed. This state is held in the " { $snippet "selected?" } " slot, and is used by the " { $link <toggle-buttons> } " word to construct a row of buttons for choosing among several alternatives." } ;
11
12 HELP: <button>
13 { $values { "label" gadget } { "quot" "a quotation with stack effect " { $snippet "( button -- )" } } { "button" "a new " { $link button } } }
14 { $description "Creates a new " { $link button } " which calls the quotation when clicked. The given gadget becomes the button's only child." } ;
15
16 HELP: <roll-button>
17 { $values { "label" "a label specifier" } { "quot" "a quotation with stack effect " { $snippet "( button -- )" } } { "button" button } }
18 { $description "Creates a new " { $link button } " which is displayed with a solid border when it is under the mouse, informing the user that the gadget is clickable." } ;
19
20 HELP: <bevel-button>
21 { $values { "label" "a label specifier" } { "quot" "a quotation with stack effect " { $snippet "( button -- )" } } { "button" button } }
22 { $description "Creates a new " { $link button } " with a shaded border which is always visible. The button appearance changes in response to mouse gestures using a " { $link button-paint } "." } ;
23
24 HELP: <repeat-button>
25 { $values { "label" object } { "quot" "a quotation with stack effect " { $snippet "( button -- )" } } { "button" repeat-button } }
26 { $description "Creates a new " { $link button } " derived from a " { $link <bevel-button> } " which calls the quotation every 100 milliseconds as long as the mouse button is held down." } ;
27
28 HELP: button-paint
29 { $class-description "A class implementing the " { $link draw-boundary } " and " { $link draw-interior } " gneeric words by delegating to an object in one of four slots which depend on the state of the button being drawn:"
30     { $list
31         { { $snippet "plain"    } " - the button is inactive" }
32         { { $snippet "rollover" } " - the button is under the mouse" }
33         { { $snippet "pressed"  } " - the button is under the mouse and a mouse button is held down" }
34         { { $snippet "selected" } " - the button is selected (see " { $link <toggle-buttons> }  }
35     }
36 "The " { $link <roll-button> } " and " { $link <bevel-button> } " words create " { $link button } " instances with specific " { $link button-paint } "." } ;
37
38 HELP: <toggle-button>
39 { $values { "model" model } { "value" object } { "label" "a label specifier" } { "gadget" gadget } }
40 { $description
41     "Creates a " { $link <bevel-button> } " which sets the model's value to " { $snippet "value" } " when pressed. After being pressed, the button becomes selected until the value of the model changes again."
42 }
43 { $notes "Typically a row of radio controls should be built together using " { $link <toggle-buttons> } "." } ;
44
45 HELP: <toggle-buttons>
46 { $values { "model" model } { "assoc" "an association list mapping labels to objects" } { "gadget" gadget } }
47 { $description "Creates a row of labelled " { $link <toggle-button> } " gadgets which change the value of the model." } ;
48
49 HELP: <command-button>
50 { $values { "target" object } { "gesture" "a gesture" } { "command" "a command" } { "button" "a new " { $link button } } }
51 { $description "Creates a " { $link <bevel-button> } " which invokes the command on " { $snippet "target" } " when clicked." } ;
52
53 HELP: <toolbar>
54 { $values { "target" object } { "toolbar" gadget } }
55 { $description "Creates a row of " { $link <command-button> } " gadgets invoking commands on " { $snippet "target" } ". The commands are taken from the " { $snippet "\"toolbar\"" } " command group of each class in " { $snippet "classes" } "." } ;
56
57 ARTICLE: "ui.gadgets.buttons" "Button gadgets"
58 "Buttons respond to mouse clicks by invoking a quotation."
59 { $subsection button }
60 "There are many ways to create a new button:"
61 { $subsection <button> }
62 { $subsection <roll-button> }
63 { $subsection <bevel-button> }
64 { $subsection <repeat-button> }
65 "Gadgets for invoking commands:"
66 { $subsection <command-button> }
67 { $subsection <toolbar> }
68 "A radio box is a row of buttons for choosing amongst several distinct possibilities:"
69 { $subsection <toggle-buttons> }
70 "Button appearance can be customized:"
71 { $subsection button-paint }
72 "Button constructors take " { $emphasis "label specifiers" } " as input. A label specifier is either a string, an array of strings, a gadget or " { $link f } "."
73 { $see-also <command-button> "ui-commands" } ;