Sometimes, you want to have programmatic access to an existing action or active settable in one of the available action bars. A use case for this would be to trigger the action through your own code.
Because all actions and active settables are registered with the TLcyActionBarManager
, you can retrieve it from there.
The following example shows how to get a reference to the File→ Exit action:
TLcyActionBarManager actionBarManager = lucy.getUserInterfaceManager().getActionBarManager();
String actionID = "TLcyMain.exitAction";
String actionBarName = "menuBar";
// Typical contexts are null for global (=application wide) action bars,
// and a map component for action bars associated with a map
Object actionBarContext = null;
ILcdAction exitAction =
TLcyActionBarUtil.findAction(actionID,
actionBarName,
actionBarContext,
actionBarManager);
The same approach can be used to retrieve an ILcyActiveSettable
.
You just need to call TLcyActionBarUtil.findActiveSettable
instead of findAction
.
See How to find the IDs of the available actions, tool bars, menu bars and pop-up menus for more information on retrieving the IDs of the action or active settable and the action bar.