diff options
| author | Juan Linietsky | 2017-05-20 12:38:03 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2017-05-20 17:05:38 -0300 |
| commit | 5b3709d3096df737b8bb2344446be818b0389bfe (patch) | |
| tree | 649a0989b1494f3c4687d59e503310f4e6bbeb40 /scene/gui/button_array.cpp | |
| parent | 93f9a83062dbe74474a4a7928758c5cf5588238e (diff) | |
| download | godot-5b3709d3096df737b8bb2344446be818b0389bfe.tar.gz godot-5b3709d3096df737b8bb2344446be818b0389bfe.tar.zst godot-5b3709d3096df737b8bb2344446be818b0389bfe.zip | |
Diffstat (limited to 'scene/gui/button_array.cpp')
| -rw-r--r-- | scene/gui/button_array.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp index eccf3ea64..0d518059c 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++) { |
