Actions
Some buttons¶
This example show a window, a box and six differents buttons.
typeof win = ObjGtkWidget;;
typeof button = ObjGtkWidget;;
typeof button2 = ObjGtkWidget;;
typeof button3 = ObjGtkWidget;;
typeof button4 = ObjGtkWidget;;
typeof button5 = ObjGtkWidget;;
typeof button6 = ObjGtkWidget;;
typeof vbox = ObjGtkWidget;;
fun CBend (obj, uparam)=
_fooId uparam;
_gtkMainQuit;
0;;
fun CBbuttonLinked (obj, uparam, uri)=
_fooS "Link !";
_fooS uri;
0;;
fun CBbuttonToggled (obj, uparam, state)=
_fooId state;
uparam;;
fun CBbutton (obj, uparam)=
_fooS strcat "user param is : " uparam;
_fooS if (obj == button) then "Ok, same button" else "No !!";
0;;
fun main ()=
_showconsole;
set win = _gtkWindowNew _channel nil "Coool !" [320 50] [500 400];
_gtkWindowCBdestroyed win @CBend 10;
set vbox = _gtkBoxNew _channel win 1 5 SCOL_GTK_BOX_VT;
set button = _gtkButtonNew _channel "My button" SCOL_GTK_BUTTON_LABEL nil;
set button2 = _gtkButtonNew _channel "gtk-open" SCOL_GTK_BUTTON_LABEL nil;
set button3 = _gtkButtonNew _channel "A link" SCOL_GTK_BUTTON_LINK "http://www.scolring.org";
set button4 = _gtkButtonNew _channel "Click !" SCOL_GTK_BUTTON_CHECK nil;
set button5 = _gtkButtonNew _channel "Toggle !" SCOL_GTK_BUTTON_TOGGLE 1;
set button6 = _gtkButtonNew _channel nil SCOL_GTK_BUTTON_SWITCH 1;
_gtkButtonCB button @CBbutton "yes !" SCOL_GTK_BUTTON_CB_CLICKED;
_gtkButtonCB button2 @CBbutton "no !" SCOL_GTK_BUTTON_CB_CLICKED;
_gtkButtonCB button4 @CBbuttonToggled 2 SCOL_GTK_BUTTON_CB_TOGGLED;
_gtkButtonCB button3 @CBbuttonLinked 0 SCOL_GTK_BUTTON_CB_LINKED;
_gtkBoxAddChilds vbox button :: button2 :: button3 :: button4 :: button5 :: button6 :: nil 0;
_gtkWidgetShowAll win;
_gtkMain;
0;;
Return Examples
Updated by iri almost 14 years ago ยท 3 revisions