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


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


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:

function_name (Process c)
  // my C++ code
  // To get the source that triggered the native action:
  Process *src = c->get_activation_source ();
  // To get the user_data:
  Process *data = (Process*) get_native_user_data (c);

c is the NativeAction that called the function.

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

function_name (Process src, Process data)
  // my Smala code

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

Predefined children



press (Process c)
 cout << "button pressed\n";

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