summaryrefslogtreecommitdiff
path: root/scene/gui/button_array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/button_array.cpp')
-rw-r--r--scene/gui/button_array.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp
index eccf3ea64a..0d518059c8 100644
--- a/scene/gui/button_array.cpp
+++ b/scene/gui/button_array.cpp
@@ -287,12 +287,12 @@ void ButtonArray::_notification(int p_what) {
}
}
-void ButtonArray::_gui_input(const InputEvent &p_event) {
+void ButtonArray::_gui_input(const Ref<InputEvent> &p_event) {
if (
- ((orientation == HORIZONTAL && p_event.is_action("ui_left")) ||
- (orientation == VERTICAL && p_event.is_action("ui_up"))) &&
- p_event.is_pressed() && selected > 0) {
+ ((orientation == HORIZONTAL && p_event->is_action("ui_left")) ||
+ (orientation == VERTICAL && p_event->is_action("ui_up"))) &&
+ p_event->is_pressed() && selected > 0) {
set_selected(selected - 1);
accept_event();
emit_signal("button_selected", selected);
@@ -300,18 +300,20 @@ void ButtonArray::_gui_input(const InputEvent &p_event) {
}
if (
- ((orientation == HORIZONTAL && p_event.is_action("ui_right")) ||
- (orientation == VERTICAL && p_event.is_action("ui_down"))) &&
- p_event.is_pressed() && selected < (buttons.size() - 1)) {
+ ((orientation == HORIZONTAL && p_event->is_action("ui_right")) ||
+ (orientation == VERTICAL && p_event->is_action("ui_down"))) &&
+ p_event->is_pressed() && selected < (buttons.size() - 1)) {
set_selected(selected + 1);
accept_event();
emit_signal("button_selected", selected);
return;
}
- if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index == BUTTON_LEFT) {
+ Ref<InputEventMouseButton> mb = p_event;
- int ofs = orientation == HORIZONTAL ? p_event.mouse_button.x : p_event.mouse_button.y;
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+
+ int ofs = orientation == HORIZONTAL ? mb->get_pos().x : mb->get_pos().y;
for (int i = 0; i < buttons.size(); i++) {
@@ -324,9 +326,11 @@ void ButtonArray::_gui_input(const InputEvent &p_event) {
}
}
- if (p_event.type == InputEvent::MOUSE_MOTION) {
+ Ref<InputEventMouseMotion> mm = p_event;
+
+ if (mm.is_valid()) {
- int ofs = orientation == HORIZONTAL ? p_event.mouse_motion.x : p_event.mouse_motion.y;
+ int ofs = orientation == HORIZONTAL ? mm->get_pos().x : mm->get_pos().y;
int new_hover = -1;
for (int i = 0; i < buttons.size(); i++) {