Merge pull request #14706 from YeldhamDev/popupmenu_submenu

Enhancements and fixes for PopupMenu's submenus
This commit is contained in:
Rémi Verschelde 2017-12-16 00:15:35 +01:00 committed by GitHub
commit 22eab86cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,24 +42,6 @@ String PopupMenu::_get_accel_text(int p_item) const {
else if (items[p_item].accel)
return keycode_get_string(items[p_item].accel);
return String();
/*
String atxt;
if (p_accel&KEY_MASK_SHIFT)
atxt+="Shift+";
if (p_accel&KEY_MASK_ALT)
atxt+="Alt+";
if (p_accel&KEY_MASK_CTRL)
atxt+="Ctrl+";
if (p_accel&KEY_MASK_META)
atxt+="Meta+";
p_accel&=KEY_CODE_MASK;
atxt+=String::chr(p_accel).to_upper();
return atxt;
*/
}
Size2 PopupMenu::get_minimum_size() const {
@ -136,7 +118,6 @@ int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
Ref<Font> font = get_font("font");
int vseparation = get_constant("vseparation");
//int hseparation = get_constant("hseparation");
float font_h = font->get_height();
for (int i = 0; i < items.size(); i++) {
@ -230,6 +211,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
mouse_over = i;
update();
if (items[i].submenu != "" && submenu_over != i) {
submenu_over = i;
submenu_timer->start();
}
break;
}
}
@ -245,6 +231,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
mouse_over = i;
update();
if (items[i].submenu != "" && submenu_over != i) {
submenu_over = i;
submenu_timer->start();
}
break;
}
}
@ -500,6 +491,13 @@ void PopupMenu::_notification(int p_what) {
} break;
case NOTIFICATION_MOUSE_EXIT: {
if (mouse_over >= 0 && (items[mouse_over].submenu == "" || submenu_over != -1)) {
mouse_over = -1;
update();
}
} break;
case NOTIFICATION_POPUP_HIDE: {
if (mouse_over >= 0) {
mouse_over = -1;
update();
@ -1217,6 +1215,7 @@ void PopupMenu::set_invalidate_click_until_motion() {
PopupMenu::PopupMenu() {
mouse_over = -1;
submenu_over = -1;
set_focus_mode(FOCUS_ALL);
set_as_toplevel(true);