Chapter 1. The various actions
Each object in a form has its own programmable actions. General actions are
- On click
script that will be executed when a mouse click on this object occurs
- On doubleclick
script that will be executed when a mouse doubleclick on this object occurs
- On open
script that will be executed when the form is created or put into viewmode
- On close
script that will be executed when the form is closed or put into designmode
Let's write a 'hello world' program. Create a new form and add a button. Select the button and click on the 'On click'-actionbutton
in the property editor. Now add the following program into the program editor
Example 1-1. Hello world-program
1 hk_this.show_warningmessage("Hello world")
2 |
Now close the window and change to viewmode. When you push the button you will see a dialog window with "Hello world".
The global variable hk_this is set from hk_classes and represents the current object, in this case the button.
show_warningmessage() is a method of this object, that allows you to display a string in a GUI independent way (as knoda is a KDE application
it will be displayed as a KDE window but if you start it within a command line program it will be displayed on the standard output).
 | Other GUI-independent ways for user interaction are
- show_warningmessage(message)
displays 'message' - bool show_yesnodialog(message, bool default_value)
displays 'message' and returns true if you answer 'yes'. The
parameter 'default_value' is used for conevience to preselect 'yes' or 'no' in dialog boxes - hk_string show_stringvaluedialog(text)
displays 'text' as a question and returns your response
|
In forms another global variable is
hk_thisform. It represents the form.
In reports the variable name is
hk_thisreport.