Stay organized with collections
Save and categorize content based on your preferences.
blockly > FieldVariable > onItemSelected_
FieldVariable.onItemSelected_() method
Handle the selection of an item in the variable dropdown menu. Special case the 'Rename variable...' and 'Delete variable...' options. In the rename case, prompt the user for a new name.
Signature:
protected onItemSelected_(menu: Menu, menuItem: MenuItem): void;
Parameters
Parameter |
Type |
Description |
menu |
Menu |
The Menu component clicked. |
menuItem |
MenuItem |
The MenuItem selected within menu. |
Returns:
void
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eonItemSelected_\u003c/code\u003e method manages actions when an item is selected from the variable dropdown within a Blockly block.\u003c/p\u003e\n"],["\u003cp\u003eIt handles special cases like renaming or deleting a variable, prompting for a new name when renaming.\u003c/p\u003e\n"],["\u003cp\u003eThis method is called with the clicked menu and the selected menu item as input.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [FieldVariable](./blockly.fieldvariable_class.md) \\\u003e [onItemSelected_](./blockly.fieldvariable_class.onitemselected__1_method.md)\n\nFieldVariable.onItemSelected_() method\n\nHandle the selection of an item in the variable dropdown menu. Special case the 'Rename variable...' and 'Delete variable...' options. In the rename case, prompt the user for a new name.\n\n**Signature:** \n\n protected onItemSelected_(menu: Menu, menuItem: MenuItem): void;\n\nParameters\n\n| Parameter | Type | Description |\n|-----------|-----------------------------------------|------------------------------------|\n| menu | [Menu](./blockly.menu_class.md) | The Menu component clicked. |\n| menuItem | [MenuItem](./blockly.menuitem_class.md) | The MenuItem selected within menu. |\n\n**Returns:**\n\nvoid"]]