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 @@ -2349,6 +2349,14 @@ void ColorPickerButton::_modal_closed() {
23492349void ColorPickerButton::pressed () {
23502350 _update_picker ();
23512351
2352+ // Checking if the popup was open before, so we can keep it closed instead of reopening it.
2353+ // Popups get closed when it's clicked outside of them.
2354+ if (popup_was_open) {
2355+ // Reset popup_was_open value.
2356+ popup_was_open = popup->is_visible ();
2357+ return ;
2358+ }
2359+
23522360 Size2 minsize = popup->get_contents_minimum_size ();
23532361 float viewport_height = get_viewport_rect ().size .y ;
23542362
@@ -2374,6 +2382,19 @@ void ColorPickerButton::pressed() {
23742382 }
23752383}
23762384
2385+ void ColorPickerButton::gui_input (const Ref<InputEvent> &p_event) {
2386+ ERR_FAIL_COND (p_event.is_null ());
2387+
2388+ Ref<InputEventMouseButton> mouse_button = p_event;
2389+ bool ui_accept = p_event->is_action (" ui_accept" , true ) && !p_event->is_echo ();
2390+ bool mouse_left_pressed = mouse_button.is_valid () && mouse_button->get_button_index () == MouseButton::LEFT && mouse_button->is_pressed ();
2391+ if (mouse_left_pressed || ui_accept) {
2392+ popup_was_open = popup && popup->is_visible ();
2393+ }
2394+
2395+ BaseButton::gui_input (p_event);
2396+ }
2397+
23772398void ColorPickerButton::_notification (int p_what) {
23782399 switch (p_what) {
23792400 case NOTIFICATION_ACCESSIBILITY_UPDATE: {
Original file line number Diff line number Diff line change @@ -514,6 +514,7 @@ class ColorPickerButton : public Button {
514514 Color color;
515515 bool edit_alpha = true ;
516516 bool edit_intensity = true ;
517+ bool popup_was_open = false ;
517518
518519 struct ThemeCache {
519520 Ref<StyleBox> normal_style;
@@ -533,6 +534,7 @@ class ColorPickerButton : public Button {
533534protected:
534535 void _notification (int );
535536 static void _bind_methods ();
537+ virtual void gui_input (const Ref<InputEvent> &p_event) override ;
536538
537539public:
538540 void set_pick_color (const Color &p_color);
You can’t perform that action at this time.
0 commit comments