User Tools

Site Tools


This is an old revision of the document!


Called Methods

For all window classes, the GuiSys (C++) code automatically calls the following script methods. These methods are intended to be provided by the GUI script author, and are the entry or “starting” point for customizing the GUI.

Note that none of these methods is obligatory, i.e. you must not provide them. The GuiSys will realize automatically which methods you provide and which you don't, and just do nothing for methods that have not been defined.


OnAction()

Called when the user pressed the “action” button inside the window. This is normally the left mouse button, but could also be the appropriate joystick button etc.


OnActivate()

Called for each window when the GUI is activated (i.e. switched on for rendering, e.g. when the user toggles the in-game console, this method is called every time for the console GUI).


OnDeactivate()

Called for each window when the GUI is deactivated.

This method mainly exists for symmetry with OnActivate(), it has little practical use.


OnFocusGain()

Called when this window gains the keyboard input focus.

  1. This not called when the focus change was triggered by the script, i.e. a call to gui:setFocus(myWin);. That is, this method is only called when the user triggered the focus change by a mouse click. If you use gui:setFocus(myWin); and want this method called, just call it yourself immediately after the call.

OnFocusLose()

Called when this window gains the keyboard input focus.

  1. This not called when the focus change was triggered by the script, i.e. a call to gui:setFocus(myWin);. That is, this method is only called when the user triggered the focus change by a mouse click.
  2. Currently, losing the focus cannot be vetoed.

OnFrame()

Called on each frame that is rendered by the Ca3D-Engine.

  1. Note that it does not get the frame time passed, but you can always learn the global time by calling get(“time”);.
  2. Oviously, you may not do many expensive things in this method — it's called every frame, after all!

OnInit()

This is the first method that is called for each window after a GUI has been loaded. It is only called once for each window.


bool OnKeyPress(Key)

This method is called if a key was pressed and the window has the keyboard input focus.

Key is a number that represents the key that has been pressed. Please refer to the CaKeyboardEventT structure that is declared in the Libs/OpenGL/OpenGLWindow.hpp file that comes with the Ca3DE SDK for possible values. Here is a list of the most frequently used values and their meaning:

Key Value Key Name
1 ESC (Escape)
2 … 11 1 … 9, 0
14 ← (Backspace)
15 TAB (Tabulator)
28 Return (on main keyboard)
41 Accent Grave
156 Enter (on numpad)
200 Arrow Up
208 Arrow Down

The method should return true if it handled this key press, and false otherwise.


bool OnKeyRelease(Key)

Like OnKeyPress(Key), but for key releases.


OnMouseEnter()

Called when the mouse cursor enters the rectangle of the window.

Note that this does currently not take rotation into account, i.e. it acts as if the rotation was always 0, even if it is actually rotating.


OnMouseLeave()

Called when the mouse cursor leaves the rectangle of the window.

Note that this does currently not take rotation into account, i.e. it acts as if the rotation was always 0, even if it is actually rotating.

guisys/called_methods.1157620834.txt.gz · Last modified: 2013-01-07 12:07 (external edit)