Project

General

Profile

Buttons explanations » History » Version 3

iri, 02/22/2011 03:46 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 2 iri
<pre><code class="php">
10 1 iri
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>
42 3 iri
43
* A button with a mnemonic :
44
A mnemonic is, by example, a keyboard shortcut
45
46
<pre><code class="php">
47
fun CBbutton (obj, uparam)=
48
	_fooS "The button has been clicked";
49
	_fooS strcat "user param is : " uparam;
50
	0;;
51
	
52
fun main ()=
53
	_showconsole;
54
	
55
	/* Create a window ...*/
56
	set win = ...
57
	/* Create the button : 
58
	- the flag. For a simple button, use SCOL_GTK_BUTTON_MNEMONIC
59
	- no supplemental parameter needed, so, nil it's ok */
60
	set button = _gtkButtonNew _channel win "My button" SCOL_GTK_BUTTON_MNEMONIC nil;
61
	/* Define the callback 
62
	- the flag. To get the "clicked" signal, use SCOL_GTK_BUTTON_CB_CLICKED */
63
	_gtkButtonCB button @CBbutton "yes !" SCOL_GTK_BUTTON_CB_CLICKED;
64
	...
65
	;;
66
</code></pre>