浏览代码

Discard button pressing flags on disable

Is it a bug?
1) Click the button and hold
2) Disable it (for example I bind this action on keyboard)
3) Release the mouse and move it outside the button
4) Enable the button
5) It's still pressed, but shouldn't
Alexey Kashlakov 7 年之前
父节点
当前提交
1e65916241
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      scene/gui/base_button.cpp

+ 8 - 0
scene/gui/base_button.cpp

@@ -315,6 +315,14 @@ void BaseButton::set_disabled(bool p_disabled) {
 		return;
 
 	status.disabled = p_disabled;
+	if (p_disabled) {
+		if (!toggle_mode) {
+			status.pressed = false;
+		}
+		status.press_attempt = false;
+		status.pressing_inside = false;
+		status.pressing_button = 0;
+	}
 	update();
 	_change_notify("disabled");
 }