![]() |
Plasma Engine
2.0
|
Stores 'actions' (things that can be triggered from UI). More...
#include <ActionManager.h>
Classes | |
struct | Event |
Static Public Member Functions | |
static plActionDescriptorHandle | RegisterAction (const plActionDescriptor &desc) |
static bool | UnregisterAction (plActionDescriptorHandle &ref_hAction) |
static const plActionDescriptor * | GetActionDescriptor (plActionDescriptorHandle hAction) |
static plActionDescriptorHandle | GetActionHandle (const char *szCategory, const char *szActionName) |
static plString | FindActionCategory (const char *szActionName) |
Searches all action categories for the given action name. Returns the category name in which the action name was found, or an empty string. | |
static plResult | ExecuteAction (const char *szCategory, const char *szActionName, const plActionContext &context, const plVariant &value=plVariant()) |
Quick way to execute an action from code. | |
static void | SaveShortcutAssignment () |
static void | LoadShortcutAssignment () |
static const plIdTable< plActionId, plActionDescriptor * >::ConstIterator | GetActionIterator () |
Static Public Attributes | |
static plEvent< const Event & > | s_Events |
Stores 'actions' (things that can be triggered from UI).
Actions are usually represented by a button in a toolbar, or a menu entry. Actions are unique across the entire application. Each action is registered exactly once, but it may be referenced by many different plActionMap instances, which defines how an action shows up in a window.
Through RegisterAction() / UnregisterAction() an action is added or removed. These functions are usually not called directly, but rather the macros at the top of this file are used (see PL_REGISTER_CATEGORY, PL_REGISTER_MENU, PL_REGISTER_ACTION_X, ...).
Unit tests can call ExecuteAction() to directly invoke an action. Widgets use plActionMap to organize which actions are available in a window, and how they are structured. For instance, the same action can appear in a menu, in a toolbar and a context menu. In each case their location may be different (top-level, in a sub-menu, etc). See plActionMap for details.
|
static |
Quick way to execute an action from code.
The use case is mostly for unit tests, which need to execute actions directly and without a link dependency on the code that registered the action.
szCategory | The category of the action, ie. under which name the action appears in the Shortcut binding dialog. For example "Scene", "Scene - Cameras", "Scene - Selection", "Assets" etc. This parameter may be nullptr in which case FindActionCategory(szActionName) is used to try to detect the category automatically. |
szActionName | The name (not mapped path) under which the action was registered. For example "Selection.Copy", "Prefabs.ConvertToEngine", "Scene.Camera.SnapObjectToCamera" |
context | The context in which to execute the action. Depending on the plActionScope of the target action, some members are optional. E.g. for document actions, only the m_pDocument member must be specified. |
value | Optional value passed through to the plAction::Execute() call. Some actions use it, most don't. |