[PopupMenu] Handle shortcuts with "global" flag directly.
This commit is contained in:
parent
9e455f424a
commit
f93e254b58
1 changed files with 12 additions and 7 deletions
|
@ -62,7 +62,7 @@ String PopupMenu::bind_global_menu() {
|
|||
if (item.separator) {
|
||||
ds->global_menu_add_separator(global_menu_name);
|
||||
} else {
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), Callable(), i);
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), item.shortcut_is_global ? callable_mp(this, &PopupMenu::activate_item) : Callable(), i);
|
||||
if (!item.submenu.is_empty()) {
|
||||
PopupMenu *pm = Object::cast_to<PopupMenu>(get_node_or_null(item.submenu));
|
||||
if (pm) {
|
||||
|
@ -1309,7 +1309,7 @@ void PopupMenu::add_shortcut(const Ref<Shortcut> &p_shortcut, int p_id, bool p_g
|
|||
|
||||
if (!global_menu_name.is_empty()) {
|
||||
DisplayServer *ds = DisplayServer::get_singleton();
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), Callable(), items.size() - 1);
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), p_global ? callable_mp(this, &PopupMenu::activate_item) : Callable(), items.size() - 1);
|
||||
if (!item.shortcut_is_disabled && item.shortcut.is_valid() && item.shortcut->has_valid_event()) {
|
||||
Array events = item.shortcut->get_events();
|
||||
for (int j = 0; j < events.size(); j++) {
|
||||
|
@ -1338,7 +1338,7 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<Shortc
|
|||
|
||||
if (!global_menu_name.is_empty()) {
|
||||
DisplayServer *ds = DisplayServer::get_singleton();
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), Callable(), items.size() - 1);
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), p_global ? callable_mp(this, &PopupMenu::activate_item) : Callable(), items.size() - 1);
|
||||
if (!item.shortcut_is_disabled && item.shortcut.is_valid() && item.shortcut->has_valid_event()) {
|
||||
Array events = item.shortcut->get_events();
|
||||
for (int j = 0; j < events.size(); j++) {
|
||||
|
@ -1368,7 +1368,7 @@ void PopupMenu::add_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_id, bo
|
|||
|
||||
if (!global_menu_name.is_empty()) {
|
||||
DisplayServer *ds = DisplayServer::get_singleton();
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), Callable(), items.size() - 1);
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), p_global ? callable_mp(this, &PopupMenu::activate_item) : Callable(), items.size() - 1);
|
||||
if (!item.shortcut_is_disabled && item.shortcut.is_valid() && item.shortcut->has_valid_event()) {
|
||||
Array events = item.shortcut->get_events();
|
||||
for (int j = 0; j < events.size(); j++) {
|
||||
|
@ -1399,7 +1399,7 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<
|
|||
|
||||
if (!global_menu_name.is_empty()) {
|
||||
DisplayServer *ds = DisplayServer::get_singleton();
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), Callable(), items.size() - 1);
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), p_global ? callable_mp(this, &PopupMenu::activate_item) : Callable(), items.size() - 1);
|
||||
if (!item.shortcut_is_disabled && item.shortcut.is_valid() && item.shortcut->has_valid_event()) {
|
||||
Array events = item.shortcut->get_events();
|
||||
for (int j = 0; j < events.size(); j++) {
|
||||
|
@ -1430,7 +1430,7 @@ void PopupMenu::add_radio_check_shortcut(const Ref<Shortcut> &p_shortcut, int p_
|
|||
|
||||
if (!global_menu_name.is_empty()) {
|
||||
DisplayServer *ds = DisplayServer::get_singleton();
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), Callable(), items.size() - 1);
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), p_global ? callable_mp(this, &PopupMenu::activate_item) : Callable(), items.size() - 1);
|
||||
if (!item.shortcut_is_disabled && item.shortcut.is_valid() && item.shortcut->has_valid_event()) {
|
||||
Array events = item.shortcut->get_events();
|
||||
for (int j = 0; j < events.size(); j++) {
|
||||
|
@ -1461,7 +1461,7 @@ void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, cons
|
|||
|
||||
if (!global_menu_name.is_empty()) {
|
||||
DisplayServer *ds = DisplayServer::get_singleton();
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), Callable(), items.size() - 1);
|
||||
int index = ds->global_menu_add_item(global_menu_name, item.xl_text, callable_mp(this, &PopupMenu::activate_item), p_global ? callable_mp(this, &PopupMenu::activate_item) : Callable(), items.size() - 1);
|
||||
if (!item.shortcut_is_disabled && item.shortcut.is_valid() && item.shortcut->has_valid_event()) {
|
||||
Array events = item.shortcut->get_events();
|
||||
for (int j = 0; j < events.size(); j++) {
|
||||
|
@ -1991,6 +1991,11 @@ void PopupMenu::set_item_shortcut(int p_idx, const Ref<Shortcut> &p_shortcut, bo
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (p_global) {
|
||||
ds->global_menu_set_item_key_callback(global_menu_name, p_idx, callable_mp(this, &PopupMenu::activate_item));
|
||||
} else {
|
||||
ds->global_menu_set_item_key_callback(global_menu_name, p_idx, Callable());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue