Getting Information About the GUI HierarchyYou can use the builtin Gsharp functions all, childrenof, exists, and typeof to return information about the GUI hierarchy. all(<class name>)When given an object class name, all returns all instances of that class. childrenof(<instance name>)The function childrenof returns the full path name of all children of a parent object. This function can be useful when updating the same resource for all instances of an object class.The following code fragment sets GUI buttons insensitive (dimmed) depending on the graph type:
Note: childrenof returns the relative name of an object, therefore the full path name of the GUI object must be constructed before using the returned child name as an object pointer. exists(<instance name>)exists returns true if an object exists, otherwise false. One useful application of this function is to test whether a GUI object exists before creating it since GUI objects are not implicitly destroyed with a reset command. For example, if you are testing code for a new dialog, you may want to begin the code with a statement like: if exists(gsharp_1.mydialog) destroy gsharp_1.mydialog; This will allow you to repeatedly run the code without having a conflict with an existing object name. Alternatively, if an object can be reused, you can avoid creating it if it already exists, as was done in the example on page 657:
typeof(<instance name>)Passed an object instance name, typeof returns the object class name.
Here is an example of where this can be useful. The Button and Icon objects
both have a XuCR_ACTIVATE callback. You could use the same callback function
for both object classes by implementing logic based on object type, as
outlined in the
Return to Gsharp Applications User Guide |