ActionGroups

[ Start > PikeModules > Module > GTK2 > ActionGroups ] [ Edit this Page | Viewing Version 1 ]


Create an Action Group

There are several types of action groups: radio, menu, toolbar, toggle, popup.

Menu actions

To create a regular menu action group, create an array like the following:

array menu_actions=({
 ([ "name": "FileMenu", "label": "_File" ]),
 ([ "name": "FileOpen", "label": "_Open",
    "callback": open_file, "data": 0 ]),
 ([ "name": "FileQuit", "label": "_Quit",
    "callback": appQuit, "data": 0 ]),
 ([ "name": "EditMenu", "label": "_Edit" ]),
 ([ "name": "EditCopy", "label": "_Copy",
    "callback": edit_copy, "data": 0 ]),
 ([ "name": "EditPast", "label": "_Paste",
    "callback": edit_past, "data": 0 ])
});

The name is what the item will be referenced in the xml definition for the UiManager. The label is what will be displayed in the menu. Callback is, of course, the actual function that will be called when the item is selected. It can be a lambda function if you wish. Data is some info that will be passed to the function, as with a normal signal. You can only pass one piece of data to the callback, but that can be anything, an array, mapping, object, or whatever, so you really aren't limited.

Radio actions

Similar to regular menu actions, but with an additional "value" parameter, and without the "data" parameter

array radio_actions=({
 ([ "name": "ViewIcons", "label": "Icons", "value": 0,
    "callback": viewAsIcons ])
})


Powered by PikeWiki2

 
gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University