Buttons explanations » History » Version 1
iri, 02/22/2011 03:43 PM
| 1 | 1 | iri | h1. Buttons explanations |
|---|---|---|---|
| 2 | |||
| 3 | To create any button, you should use [[Create|_gtkButtonNew]] |
||
| 4 | |||
| 5 | How to create them ? |
||
| 6 | |||
| 7 | * A simple button with a label : |
||
| 8 | |||
| 9 | <pre><code class="ruby"> |
||
| 10 | typeof win = ObjGtkWidget;; |
||
| 11 | typeof button = ObjGtkWidget;; |
||
| 12 | |||
| 13 | fun CBbutton (obj, uparam)= |
||
| 14 | _fooS "The button has been clicked"; |
||
| 15 | _fooS strcat "user param is : " uparam; |
||
| 16 | 0;; |
||
| 17 | |||
| 18 | fun main ()= |
||
| 19 | _showconsole; |
||
| 20 | |||
| 21 | /* Create a window ...*/ |
||
| 22 | set win = ... |
||
| 23 | /* Create the button : |
||
| 24 | use _gtkButtonNew function with : |
||
| 25 | - the channel |
||
| 26 | - the parent (here a window) |
||
| 27 | - the label |
||
| 28 | - the flag. For a simple button, use SCOL_GTK_BUTTON_LABEL |
||
| 29 | - no supplemental parameter needed, so, nil it's ok */ |
||
| 30 | set button = _gtkButtonNew _channel win "My button" SCOL_GTK_BUTTON_LABEL nil; |
||
| 31 | /* Define the callback |
||
| 32 | use _gtkButtonCB with : |
||
| 33 | - the Scol object |
||
| 34 | - the reflex |
||
| 35 | - any parameter at your convenience |
||
| 36 | - the flag. To get the "clicked" signal, use SCOL_GTK_BUTTON_CB_CLICKED |
||
| 37 | It's all*/ |
||
| 38 | _gtkButtonCB button @CBbutton "yes !" SCOL_GTK_BUTTON_CB_CLICKED; |
||
| 39 | ... |
||
| 40 | ;; |
||
| 41 | </code></pre> |