2
0
Эх сурвалжийг харах

Merge pull request #26105 from nekomatata/texture-button-mask-fix

TextureButton with click mask only can be clicked
Rémi Verschelde 6 жил өмнө
parent
commit
47c4ec7f1d

+ 5 - 1
scene/gui/texture_button.cpp

@@ -64,7 +64,9 @@ bool TextureButton::has_point(const Point2 &p_point) const {
 		Rect2 rect = Rect2();
 		Rect2 rect = Rect2();
 		Size2 mask_size = click_mask->get_size();
 		Size2 mask_size = click_mask->get_size();
 
 
-		if (_tile) {
+		if (_position_rect.no_area()) {
+			rect.size = mask_size;
+		} else if (_tile) {
 			// if the stretch mode is tile we offset the point to keep it inside the mask size
 			// if the stretch mode is tile we offset the point to keep it inside the mask size
 			rect.size = mask_size;
 			rect.size = mask_size;
 			if (_position_rect.has_point(point)) {
 			if (_position_rect.has_point(point)) {
@@ -216,6 +218,8 @@ void TextureButton::_notification(int p_what) {
 					draw_texture_rect(texdraw, _position_rect, _tile);
 					draw_texture_rect(texdraw, _position_rect, _tile);
 				else
 				else
 					draw_texture_rect_region(texdraw, _position_rect, _texture_region);
 					draw_texture_rect_region(texdraw, _position_rect, _texture_region);
+			} else {
+				_position_rect = Rect2();
 			}
 			}
 			if (has_focus() && focused.is_valid()) {
 			if (has_focus() && focused.is_valid()) {