Skip to main content

click

Description

fires on clicking an item of Action Menu or outside the menu

Parameters

  • ev - event object
    • context - object for which menu was called, optional
    • action - object of selected menu item, empty if menu was closed by an outside click
    • ev - 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