set_action_and_target_value
Description:
Sets or unsets the "action" and "target" attributes of this.
If action
is null then both the "action" and "target" attributes are unset (and
target_value
is ignored).
If action
is non-null then the "action" attribute is set. The "target" attribute is then set to
the value of target_value
if it is non-null or unset otherwise.
Normal menu items (ie: not submenu, section or other custom item types) are expected to have the "action" attribute set to identify the action that they are associated with. The state type of the action help to determine the disposition of the menu item. See Action and ActionGroup for an overview of actions.
In general, clicking on the menu item will result in activation of the named action with the "target" attribute given as the parameter to the action invocation. If the "target" attribute is not set then the action is invoked with no parameter.
If the action has no state then the menu item is usually drawn as a plain menu item (ie: with no additional decoration).
If the action has a boolean state then the menu item is usually drawn as a toggle menu item (ie: with a checkmark or equivalent indication). The item should be marked as 'toggled' or 'checked' when the boolean state is true.
If the action has a string state then the menu item is usually drawn as a radio menu item (ie: with a radio bullet or equivalent indication).
The item should be marked as 'selected' when the string state is equal to the value of the target
property.
See set_action_and_target or set_detailed_action for two equivalent calls that are probably more convenient for most uses.
Parameters:
this |
a MenuItem |
action |
the name of the action for this item |
target_value |
a Variant to use as the action target |