NativeAction

The process NativeAction allows to call native code written in C++ or to create new Smala processes during the program execution.

Constructor

NativeAction <id> (function_name, data, <0|1>)

Action

Runs the function function_name and makes data available to it. The data parameter is optional. The last parameter specifies wether or not the component must be activated on tree traversal, that is when its parent is activated. If written in C++, the syntax of function_name must be:


_action_
function_name (Component c)
%{
my C++ code
%}
        

c is the NativeAction that called the function.

If written in Smala, the syntax of function_name must be:


_action_
function_name (Component src, Component data)
{
my Smala code
}

src is the process that triggered the NativeAction, data is the data argument of the NativeAction.

Predefined children

None.

Example


_action_
press (Component c)
%{
 cout << "button pressed\n";
%}

_main_
Component root {
  Frame f ("Hello Interaction!", 0, 0, 500, 400)
  Rectangle r (50, 50, 100, 70, 0, 0)
  NativeAction press_action (press, 1)
  r.press -> press_action
}