From 4b3c8aed30fba416ed3ed31c72132f49c830c969 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 17 Nov 2022 23:04:16 +0100 Subject: [PATCH] Now ColorSelectorButton can work both in toggle mode, and in normal mode. --- scene/gui/color_picker.cpp | 14 +++++++++++--- scene/gui/color_picker.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 79abd0122..1a8f6cce1 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -1246,8 +1246,7 @@ void ColorSelectorButton::_update_picker() { picker->connect("color_changed", this, "_color_changed"); popup->connect("modal_closed", this, "_modal_closed"); popup->connect("about_to_show", this, "_about_to_show"); - popup->connect("popup_hide", this, "set_pressed", varray(false)); - popup->connect("popup_hide", this, "set_toggle_mode", varray(false)); + //popup->connect("popup_hide", this, "set_pressed", varray(false)); picker->set_pick_color(color); picker->set_edit_alpha(edit_alpha); picker->set_display_old_color(true); @@ -1259,10 +1258,18 @@ void ColorSelectorButton::pressed() { if (_button == BUTTON_LEFT) { Button::pressed(); } else if (_button == BUTTON_RIGHT) { - set_toggle_mode(true); popup_open_request(); } } +void ColorSelectorButton::toggled(bool p_pressed) { + if (_button == BUTTON_LEFT) { + Button::toggled(p_pressed); + } else if (_button == BUTTON_RIGHT) { + if (p_pressed) { + popup_open_request(); + } + } +} void ColorSelectorButton::_gui_input(Ref p_event) { Ref mouse_button = p_event; @@ -1302,4 +1309,5 @@ ColorSelectorButton::ColorSelectorButton() { edit_alpha = true; set_button_mask(BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT); + //set_toggle_mode(true); } diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index 3424d5ceb..77ce4563e 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -219,6 +219,7 @@ class ColorSelectorButton : public Button { protected: void pressed(); + void toggled(bool p_pressed); void _gui_input(Ref p_event); void _notification(int);