Tutorial Chapter 12: Changing the User Interface Dynamically |
Included in the predefined functions that are built into Genero are special groups (classes) of functions (methods) that act upon the objects that are created when your program is running. Each class of methods interacts with a specific program object, allowing you to change the appearance or behavior of the objects. Because these methods act upon program objects, the syntax is somewhat different from that of functions.
The classes are gathered together into packages:
This tutorial focuses on using the classes and methods in the ui package to modify the user interface at runtime.
This example for the Window class also presents the general process that you should use.
The methods in the Window class interact with the Window objects in your program.
Before you can call any of the methods associated with Window objects, you must identify the specific Window object that you wish to affect, and obtain a reference to it:
DEFINE mywin ui.Window
OPEN WINDOW w1 WITH FORM "testform"
LET mywin = ui.Window.getCurrent() -- returns a reference to -- the current window object LET mywin = ui.Window.forName("w1")-- returns a reference to -- the open window named "w1"
CALL mywin.setText("test")
See The Window class in the Genero Business Development Language User Guide for a complete list of the methods in this class.
01 MAIN 02 DEFINE mywin ui.Window 03 04 OPEN WINDOW w1 WITH FORM "testform" 05 LET mywin = ui.Window.getCurrent() 06 CALL mywin.setText("test") 07 MENU 08 ON ACTION quit 09 EXIT MENU 10 END MENU 11 12 END MAIN
Figure 1. Form with window title changed by the ui.Window.setText method