aboutsummaryrefslogtreecommitdiff
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.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp
index eccf3ea64..1616272e6 100644
--- a/scene/gui/button_array.cpp
+++ b/scene/gui/button_array.cpp
@@ -236,8 +236,8 @@ void ButtonArray::_notification(int p_what) {
}
Rect2 r;
- r.pos[orientation] = ofs;
- r.pos[!orientation] = 0;
+ r.position[orientation] = ofs;
+ r.position[!orientation] = 0;
r.size[orientation] = s;
r.size[!orientation] = op_size;
@@ -272,10 +272,10 @@ void ButtonArray::_notification(int p_what) {
Point2 text_ofs = ((r.size - ssize - sbsize) / 2.0 + Point2(0, f->get_ascent())).floor() + sbofs;
if (buttons[i].icon.is_valid()) {
- draw_texture(buttons[i].icon, r.pos + Point2(text_ofs.x, Math::floor((r.size.height - buttons[i].icon->get_height()) / 2.0)));
+ draw_texture(buttons[i].icon, r.position + Point2(text_ofs.x, Math::floor((r.size.height - buttons[i].icon->get_height()) / 2.0)));
text_ofs.x += buttons[i].icon->get_width() + icon_sep;
}
- draw_string(f, text_ofs + r.pos, buttons[i].xl_text, c);
+ draw_string(f, text_ofs + r.position, buttons[i].xl_text, c);
buttons[i]._pos_cache = ofs;
buttons[i]._size_cache = s;
@@ -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_position().x : mb->get_position().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_position().x : mm->get_position().y;
int new_hover = -1;
for (int i = 0; i < buttons.size(); i++) {