Chapter 1. The various actions
Prev | The KNODA scripting tutorial | Next

## 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

On getfocus

  script that will be executed when this object gets the keyboard focus

On loosefocus

  script that will be executed when this object looses the keyboard focus

On key

  script that will be executed when this object has the keyboard focus and a key on the keyboard is pressed

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

    hk_this.show_warningmessage("Hello world")

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).

### Important

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 convenience 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.

Prev | Up | Next
The KNODA scripting tutorial | Home | Chapter 2. General object methods- the class hk_visible