瀏覽代碼

TextureButton Fix logic for drawing only the focus texture

(cherry picked from commit 078b8c25ce286558a7cfc09034c4ec4e763165eb)
kleonc 3 年之前
父節點
當前提交
b2e5e7cd89
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      scene/gui/texture_button.cpp

+ 3 - 2
scene/gui/texture_button.cpp

@@ -171,7 +171,8 @@ void TextureButton::_notification(int p_what) {
 			bool draw_focus = (has_focus() && focused.is_valid());
 
 			// If no other texture is valid, try using focused texture.
-			if (!texdraw.is_valid() && draw_focus) {
+			bool draw_focus_only = draw_focus && !texdraw.is_valid();
+			if (draw_focus_only) {
 				texdraw = focused;
 			}
 
@@ -230,7 +231,7 @@ void TextureButton::_notification(int p_what) {
 				size.width *= hflip ? -1.0f : 1.0f;
 				size.height *= vflip ? -1.0f : 1.0f;
 
-				if (texdraw == focused) {
+				if (draw_focus_only) {
 					// Do nothing, we only needed to calculate the rectangle.
 				} else if (_tile) {
 					draw_texture_rect(texdraw, Rect2(ofs, size), _tile);