diff options
| author | eikobear <kokumeiko@gmail.com> | 2022-01-28 17:03:45 -0500 |
|---|---|---|
| committer | eikobear <kokumeiko@gmail.com> | 2022-01-28 17:03:45 -0500 |
| commit | 3b146c5eaa06d9f6827c651802b9fb2a9a1e013d (patch) | |
| tree | 2085ef8738060221f8cd5dae2492d4b02408c096 /scene/gui/popup_menu.cpp | |
| parent | b9a2569be6fcd1127454127d989b504334d2dac8 (diff) | |
| download | redot-engine-3b146c5eaa06d9f6827c651802b9fb2a9a1e013d.tar.gz | |
Make various improvements to OptionButton
- Allow OptionButton selection to be set to -1 to signify no selection, both via API and in the editor.
- Reset OptionButton selection to -1 when the selected item has been removed.
- Fully convert PopupMenu to a zero-based ID system, which improves an inconsistency in generated IDs when making new items in the editor.
Diffstat (limited to 'scene/gui/popup_menu.cpp')
| -rw-r--r-- | scene/gui/popup_menu.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index c9fddc3e17..fc853a3df4 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -810,7 +810,7 @@ void PopupMenu::_notification(int p_what) { #define ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel) \ item.text = p_label; \ item.xl_text = atr(p_label); \ - item.id = p_id == -1 ? items.size() : p_id; \ + item.id = p_id == -1 ? items.size() - 1 : p_id; \ item.accel = p_accel; void PopupMenu::add_item(const String &p_label, int p_id, Key p_accel) { @@ -892,7 +892,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int _ref_shortcut(p_shortcut); \ item.text = p_shortcut->get_name(); \ item.xl_text = atr(item.text); \ - item.id = p_id == -1 ? items.size() : p_id; \ + item.id = p_id == -1 ? items.size() - 1 : p_id; \ item.shortcut = p_shortcut; \ item.shortcut_is_global = p_global; @@ -961,7 +961,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, Item item; item.text = p_label; item.xl_text = atr(p_label); - item.id = p_id == -1 ? items.size() : p_id; + item.id = p_id == -1 ? items.size() - 1 : p_id; item.submenu = p_submenu; items.push_back(item); _shape_item(items.size() - 1); |
