File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2446,6 +2446,14 @@ void ColorPickerButton::_modal_closed() {
24462446void ColorPickerButton::pressed () {
24472447 _update_picker ();
24482448
2449+ // Checking if the popup was open before, so we can keep it closed instead of reopening it.
2450+ // Popups get closed when it's clicked outside of them.
2451+ if (popup_was_open) {
2452+ // Reset popup_was_open value.
2453+ popup_was_open = popup->is_visible ();
2454+ return ;
2455+ }
2456+
24492457 Size2 minsize = popup->get_contents_minimum_size ();
24502458 float viewport_height = get_viewport_rect ().size .y ;
24512459
@@ -2471,6 +2479,19 @@ void ColorPickerButton::pressed() {
24712479 }
24722480}
24732481
2482+ void ColorPickerButton::gui_input (const Ref<InputEvent> &p_event) {
2483+ ERR_FAIL_COND (p_event.is_null ());
2484+
2485+ Ref<InputEventMouseButton> mouse_button = p_event;
2486+ bool ui_accept = p_event->is_action (" ui_accept" , true ) && !p_event->is_echo ();
2487+ bool mouse_left_pressed = mouse_button.is_valid () && mouse_button->get_button_index () == MouseButton::LEFT && mouse_button->is_pressed ();
2488+ if (mouse_left_pressed || ui_accept) {
2489+ popup_was_open = popup && popup->is_visible ();
2490+ }
2491+
2492+ BaseButton::gui_input (p_event);
2493+ }
2494+
24742495void ColorPickerButton::_notification (int p_what) {
24752496 switch (p_what) {
24762497 case NOTIFICATION_ACCESSIBILITY_UPDATE: {
Original file line number Diff line number Diff line change @@ -521,6 +521,7 @@ class ColorPickerButton : public Button {
521521 Color color;
522522 bool edit_alpha = true ;
523523 bool edit_intensity = true ;
524+ bool popup_was_open = false ;
524525
525526 struct ThemeCache {
526527 Ref<StyleBox> normal_style;
@@ -540,6 +541,7 @@ class ColorPickerButton : public Button {
540541protected:
541542 void _notification (int );
542543 static void _bind_methods ();
544+ virtual void gui_input (const Ref<InputEvent> &p_event) override ;
543545
544546public:
545547 void set_pick_color (const Color &p_color);
You can’t perform that action at this time.
0 commit comments