ContextAction
ContextAction
A discoverable action that can be offered based on current context. More…
#include <ContextAction.hpp>
Public Attributes
| Name | |
|---|---|
| QString | action_id Unique identifier (e.g., “scatter_plot.visualize_2d”). |
| QString | display_name User-visible label (e.g., “Visualize in Scatter Plot”). |
| QString | icon Optional icon resource path. |
| EditorLib::EditorTypeId | producer_type Widget type that provides this action. |
| std::function< bool(SelectionContext const &)> | is_applicable Predicate: can this action run in the current context? |
| std::function< void(SelectionContext const &)> | execute Execute the action. |
Detailed Description
struct ContextAction;A discoverable action that can be offered based on current context.
Widgets register ContextActions during startup. When the user right-clicks a data key (or opens an action palette), the system queries all registered actions and shows those whose is_applicable predicate returns true.
Example
ContextAction action;
action.action_id = "scatter_plot.visualize_2d";
action.display_name = "Visualize in Scatter Plot";
action.is_applicable = [dm](SelectionContext const & ctx) {
auto * tensor = dm->getData<TensorData>(ctx.dataFocus().toStdString());
return tensor && tensor->numColumns() >= 2;
};
action.execute = [registry](SelectionContext const & ctx) {
// Open scatter plot, configure axes from focused tensor
};
selection_context->registerAction(std::move(action));Public Attributes Documentation
variable action_id
QString action_id;Unique identifier (e.g., “scatter_plot.visualize_2d”).
variable display_name
QString display_name;User-visible label (e.g., “Visualize in Scatter Plot”).
variable icon
QString icon;Optional icon resource path.
variable producer_type
EditorLib::EditorTypeId producer_type;Widget type that provides this action.
variable is_applicable
std::function< bool(SelectionContext const &)> is_applicable;Predicate: can this action run in the current context?
variable execute
std::function< void(SelectionContext const &)> execute;Execute the action.
Updated on 2026-11-13 at 20:25:39 +0000