click
Description
Optional.Fires on clicking an item of Action Menu or outside the menuUsage
onclick?: (ev: {
context?: any;
action: IMenuOption; // @deprecated use `option` instead. Will be removed in v3.0
option: IMenuOption;
event?: MouseEvent;
}) => void;
Parameters
- ev - an event object with the next parameters:
context
- (optional) an object for which menu was calledaction
- (required) the object of selected (clicked) menu item, empty if menu was closed by an outside click (for the IMenuOption parameters description refer to options)option
- (required) same asaction
event
- (optional) a native html event
Example
<script>
let message = "";
function clicked(ev){
const action = ev.action;
message = action ? `clicked on ${action.id}` : "closed";
}
let menu = $state();
</script>
<ActionMenu {options} onclick={clicked} bind:this={menu}/>
<Button type="primary" onclick={menu.show}>Click me</Button>
Details
You can get an object of the clicked option inside the event as in the above example. The event object will contain an object related to the clicked menu item.
Related article: Catching the change of a clicked option
Related sample: Action Menu