Description
The AddOption
method is used to add a new option to the toolbar in the editor. This method allows you to specify a text label, an icon, and an action that will be executed when the option is selected. It returns an Editor.Option
object representing the newly added option.
Usage
To use the AddOption
method, you need to provide the following parameters:
text
: A string
representing the label of the option.
icon
: A string
representing the icon associated with the option. This should be the path or identifier of the icon resource.
action
: An Action
delegate that defines the behavior to execute when the option is selected.
Once called, the method will add the option to the toolbar and return an Editor.Option
object.
Example
// Example of adding an option to a toolbar
Editor.ToolBar toolbar = new Editor.ToolBar();
// Define the action to be performed when the option is selected
System.Action myAction = () => {
// Action logic here
// For example, open a dialog or execute a command
};
// Add the option to the toolbar
Editor.Option newOption = toolbar.AddOption("My Option", "icon_path", myAction);
// Optionally, you can further configure the returned Editor.Option object
newOption.Enabled = true; // Enable or disable the option
newOption.Tooltip = "This is my custom option"; // Set a tooltip for the option