![]() |
XII Release 0.1.0
|
Stores 'actions' (things that can be triggered from UI). More...
#include <ActionManager.h>
Classes | |
struct | Event |
Static Public Member Functions | |
static xiiActionDescriptorHandle | RegisterAction (const xiiActionDescriptor &desc) |
static bool | UnregisterAction (xiiActionDescriptorHandle &ref_hAction) |
static const xiiActionDescriptor * | GetActionDescriptor (xiiActionDescriptorHandle hAction) |
static xiiActionDescriptorHandle | GetActionHandle (xiiStringView sCategory, xiiStringView sActionName) |
static xiiString | FindActionCategory (xiiStringView sActionName) |
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 xiiResult | ExecuteAction (xiiStringView sCategory, xiiStringView sActionName, const xiiActionContext &context, const xiiVariant &value=xiiVariant()) |
Quick way to execute an action from code. | |
static void | SaveShortcutAssignment () |
static void | LoadShortcutAssignment () |
static const xiiIdTable< xiiActionId, xiiActionDescriptor * >::ConstIterator | GetActionIterator () |
Static Public Attributes | |
static xiiEvent< 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 xiiActionMap 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 XII_REGISTER_CATEGORY, XII_REGISTER_MENU, XII_REGISTER_ACTION_X, ...).
Unit tests can call ExecuteAction() to directly invoke an action. Widgets use xiiActionMap 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 xiiActionMap 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.
sCategory | 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(sActionName) is used to try to detect the category automatically. |
sActionName | 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 xiiActionScope 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 xiiAction::Execute() call. Some actions use it, most don't. |