executeAction method

bool executeAction(
  1. String actionId
)

Executes a NodeFlow action by its ID.

This method looks up the action in the controller's shortcuts system, checks if it can be executed, and then executes it if possible.

Parameters:

  • actionId: The unique identifier of the action to execute

Returns true if the action was executed, false otherwise.

Example:

if (executeAction('delete_selection')) {
  print('Deleted selected items');
} else {
  print('Could not delete (maybe nothing selected)');
}

Implementation

bool executeAction(String actionId) {
  final controller = nodeFlowController;
  if (controller == null) return false;

  final action = controller.shortcuts.getAction(actionId);
  if (action != null && action.canExecute(controller)) {
    return action.execute(controller, context);
  }
  return false;
}