Skip to main content

onclick

Description

Fires when a control within the toolbar is clicked

Usage

onclick?: (ev: {
item: {
id?: string | number;
comp?: string;
icon?: string;
css?: string;
text?: string;
menuText?: string;
key?: string;
spacer?: boolean;
collapsed?: boolean;
handler?: (item: item, value?: any) => void;
layout?: "column";
items?: item[];
[key: string]: any;
};
}) => void;

Parameters

The callback receives a single parameter ev – an object with the following field:

  • item – (required) the toolbar item that was clicked. For the full description of toolbar item properties, see items

Example

type OnClickResult {
// clicked control item
item: {
id: string;
};
}

onclick(ev: OnClickResult): void

Handling control click events:

<script>
const items = [
{ id: "name", comp: "button" },
{ id: "email", comp: "button" },
];

function handler(ev) {
const { item } = ev;
console.log("clicked control", item.id);
}
</script>

<Toolbar {items} onclick={handler} />