Actions

As mentioned above, InterViews uses Action objects to do callbacks for things like buttons, menus, etc. These are done (for now) via preprocessor macros, although this will eventually get changed to use templates. The code fragment below shows how to create a callback to a particular method of an object.



class App {
  void mymethod();
};

declareActionCallback(App);
implementActionCallback(App);

void App:mymethod() { /* handle the callback */ }

main() {
  App* a = new App;
  session->run_window(
     new ApplicationWindow(
        kit.inset_frame(
           layout.hbox(
                 kit.push_button("Mymethod",
                                 new ActionCallback(App)(a, &App:mymethod)
                 ),
                 layout.hglue(),
                 kit.push_button("Quit", &Session::instance()->quit)
           )
        )
     )
  );
}