Merge pull request #51906 from requizm/fix/49077

Fix tooltips don't appear for PopupMenus
This commit is contained in:
Michael Alexsander 2021-08-28 15:43:02 +00:00 committed by GitHub
commit 565ba91d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -228,6 +228,7 @@ void PopupMenu::_activate_submenu(int p_over) {
// Set autohide areas
PopupMenu *submenu_pum = Object::cast_to<PopupMenu>(submenu_popup);
if (submenu_pum) {
submenu_pum->take_mouse_focus();
// Make the position of the parent popup relative to submenu popup
this_rect.position = this_rect.position - submenu_pum->get_position();

View file

@ -46,6 +46,7 @@
#include "scene/gui/control.h"
#include "scene/gui/label.h"
#include "scene/gui/popup.h"
#include "scene/gui/popup_menu.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/window.h"
#include "scene/resources/mesh.h"
@ -1101,6 +1102,12 @@ String Viewport::_gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Cont
while (p_control) {
tooltip = p_control->get_tooltip(pos);
//Temporary solution for PopupMenus
PopupMenu *menu = Object::cast_to<PopupMenu>(this);
if (menu) {
tooltip = menu->get_tooltip(pos);
}
if (r_tooltip_owner) {
*r_tooltip_owner = p_control;
}