You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Merge pull request #98428 from pafuent/fixing_color_picker_closing_popup_on_mouse_click
Fix `ColorPickerButton` close popup on mouse click
This commit is contained in:
@@ -2349,6 +2349,14 @@ void ColorPickerButton::_modal_closed() {
|
||||
void ColorPickerButton::pressed() {
|
||||
_update_picker();
|
||||
|
||||
// Checking if the popup was open before, so we can keep it closed instead of reopening it.
|
||||
// Popups get closed when it's clicked outside of them.
|
||||
if (popup_was_open) {
|
||||
// Reset popup_was_open value.
|
||||
popup_was_open = popup->is_visible();
|
||||
return;
|
||||
}
|
||||
|
||||
Size2 minsize = popup->get_contents_minimum_size();
|
||||
float viewport_height = get_viewport_rect().size.y;
|
||||
|
||||
@@ -2374,6 +2382,19 @@ void ColorPickerButton::pressed() {
|
||||
}
|
||||
}
|
||||
|
||||
void ColorPickerButton::gui_input(const Ref<InputEvent> &p_event) {
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
|
||||
Ref<InputEventMouseButton> mouse_button = p_event;
|
||||
bool ui_accept = p_event->is_action("ui_accept", true) && !p_event->is_echo();
|
||||
bool mouse_left_pressed = mouse_button.is_valid() && mouse_button->get_button_index() == MouseButton::LEFT && mouse_button->is_pressed();
|
||||
if (mouse_left_pressed || ui_accept) {
|
||||
popup_was_open = popup && popup->is_visible();
|
||||
}
|
||||
|
||||
BaseButton::gui_input(p_event);
|
||||
}
|
||||
|
||||
void ColorPickerButton::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
|
||||
|
||||
Reference in New Issue
Block a user