From fd285e19edd37111f0e61004ed7a25d3540dbe7e Mon Sep 17 00:00:00 2001 From: Rindbee Date: Mon, 13 Jun 2022 18:54:48 +0800 Subject: [PATCH] Fix the bug that the sampling position is reversed, make eyedrop reusable. --- scene/gui/color_picker.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 5fff1e1df3f..28d645e8f63 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -1108,7 +1108,7 @@ void ColorPicker::_screen_input(const Ref &p_event) { Ref img = r->get_texture()->get_image(); if (img.is_valid() && !img->is_empty()) { Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position(); - Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y); + Color c = img->get_pixel(ofs.x, ofs.y); set_pick_color(c); } @@ -1135,6 +1135,8 @@ void ColorPicker::_screen_pick_pressed() { screen->connect("gui_input", callable_mp(this, &ColorPicker::_screen_input)); // It immediately toggles off in the first press otherwise. screen->call_deferred(SNAME("connect"), "hidden", Callable(btn_pick, "set_pressed"), varray(false)); + } else { + screen->show(); } screen->raise(); #ifndef _MSC_VER