GUI Object Functions
Gsharp contains a number of functions for working with GUI objects. These
are:
The following functions work with both GUI and graphical functions
- all -
return list of all objects of specified type
- childrenof
- return list of children of object
- exists
- return true if object exists
- typeof
- return type of object
GuiGetString - return the text value
of an object
| Syntax: |
string GuiGetString(string OBJ) |
| Description: |
Returns the text from any GUI object with
an input field component, such as the Text object or Dialog types
with an input component. |
| Example 1: |
filename = GuiGetString("gsharp_1.mydialog.filename");
import_report(filename);
|
| Example 2: |
n = strvalue(GuiGetString("gsharp_1.mydialog.n"));
GuiSetString("gsharp_1.mydialog.n",''+nint(n),false);
|
| See also: |
GuiSetString |
GuiPopdownDialog - popdown a
dialog
| Syntax: |
GuiPopdownDialog(string DIALOG) |
| Description: |
Pops down the dialog specified by DIALOG |
| Example 1: |
GuiPopdownDialog("gsharp_1.mydialog")
|
| Example 2: |
#Name of dialog is calculated from the object o
function PopdownDialogCB(string o, string d, float r)
o = tokenize(o,".");
GuiPopdownDialog(o[1]+"."+o[2]);
endfunction
|
| See also: |
GuiPopupDialog |
GuiPopupDialog - popup a dialog
| Syntax: |
GuiPopupDialog(string DIALOG) |
| Description: |
Pop up the dialog specified by DIALOG |
| Example 1: |
GuiPopupDialog("gsharp_1.mydialog")
|
| Example 2: |
#Popup dialog specified in callback data
function PopupDialogCB(string o, string d, float r)
GuiPopupDialog(d);
endfunction
|
| See also: |
GuiPopdownDialog |
GuiSetString - set the text value
of an object
| Syntax: |
GuiSetString(string OBJ, string
value, float callback) |
| Description: |
Set the text of any GUI object with an input
field component to the specified value.
- If callback is true, then the callback of the object
is called with a reason XuCR_ACTIVATE
|
| Example 1: |
GuiSetString("gsharp_1.fileopen","c:\\default.txt", false);
|
| Example 2: |
GuiSetString(o,toupper(GuiGetString(o)),false);
|
| See also: |
GuiGetString |
GuiSwitchGetState - get the
state of a switch object
| Syntax: |
float GuiSwitchGetState(string OBJ) |
| Description: |
Get the state of a switch object.
- If the switch is selected GuiSwitchGetState returns true,
if it is not selected it returns false.
|
| Example 1: |
autoRepaint =
GuiSwitchGetState("gsharp_1.scrolledcanvas.popup.AutoRepaint");
|
| Example 2: |
#Change label of switch to "on" or "off" as appropriate.
function StandardToggleCB(string o, string d, float r)
$o.XuNguiLabel = if(GuiSwitchGetState(o), "On", "Off");
endfunction
|
| See also: |
GuiSwitchSetState |
GuiSwitchSetState - set the
state of a switch object
| Syntax: |
GuiSwitchSetState(string OBJ,
float value, float callback) |
| Description: |
Set the state of a switch object to value.
- If value is true, then the switch is selected,
if it is false - it is unselected.
- If callback is true, then the callback of the switch
is called with a reason XuCR_ACTIVATE
|
| Example 1: |
GuiSwitchSetState("gsharp_1.menubar.menu1.option1",true,true);
|
| Example 2: |
#callback to implement radio buttons
function GuiRadioButtonCB(string o, string d, float r)
string child, parent;
child = strrchr(o,".");
parent = substr(o,1,strlen(o)-strlen(child));
for child in parent+"."+childrenof($parent)
if typeof($child)<>"Switch" continue;
if $child.XuNguiSwitchType<>"radio" continue;
GuiSwitchSetState(child, o=child, false);
endfor
endfunction
|
| See also: |
GuiSwitchGetState |
Return to Gsharp Applications
Reference Manual
|