summaryrefslogtreecommitdiff
path: root/scene/gui/menu_button.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/menu_button.cpp')
-rw-r--r--scene/gui/menu_button.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index dc6c7fec28..ceb2092e3a 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -33,7 +33,7 @@
#include "core/os/keyboard.h"
#include "scene/main/window.h"
-void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
+void MenuButton::unhandled_key_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (!_is_focus_owner_in_shorcut_context()) {
@@ -87,21 +87,23 @@ void MenuButton::_popup_visibility_changed(bool p_visible) {
void MenuButton::pressed() {
emit_signal(SNAME("about_to_popup"));
- Size2 size = get_size();
+ Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
+ popup->set_size(Size2(size.width, 0));
Point2 gp = get_screen_position();
- gp.y += get_size().y;
-
+ gp.y += size.y;
+ if (is_layout_rtl()) {
+ gp.x += size.width - popup->get_size().width;
+ }
popup->set_position(gp);
+ popup->set_parent_rect(Rect2(Point2(gp - popup->get_position()), size));
- popup->set_size(Size2(size.width, 0));
- popup->set_parent_rect(Rect2(Point2(gp - popup->get_position()), get_size()));
popup->take_mouse_focus();
popup->popup();
}
-void MenuButton::_gui_input(Ref<InputEvent> p_event) {
- BaseButton::_gui_input(p_event);
+void MenuButton::gui_input(const Ref<InputEvent> &p_event) {
+ BaseButton::gui_input(p_event);
}
PopupMenu *MenuButton::get_popup() const {
@@ -172,7 +174,7 @@ MenuButton::MenuButton() {
popup = memnew(PopupMenu);
popup->hide();
- add_child(popup);
+ add_child(popup, false, INTERNAL_MODE_FRONT);
popup->connect("about_to_popup", callable_mp(this, &MenuButton::_popup_visibility_changed), varray(true));
popup->connect("popup_hide", callable_mp(this, &MenuButton::_popup_visibility_changed), varray(false));
}