浏览代码

Show a warning if you try to grab focus when not allowed, closes #15388

Juan Linietsky 7 年之前
父节点
当前提交
f6fbf841d5
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      scene/gui/control.cpp

+ 4 - 1
scene/gui/control.cpp

@@ -2062,8 +2062,11 @@ void Control::grab_focus() {
 	if (!is_inside_tree()) {
 	if (!is_inside_tree()) {
 		ERR_FAIL_COND(!is_inside_tree());
 		ERR_FAIL_COND(!is_inside_tree());
 	}
 	}
-	if (data.focus_mode == FOCUS_NONE)
+
+	if (data.focus_mode == FOCUS_NONE) {
+		WARN_PRINT("This control can't grab focus. Use set_focus_mode() to allow a control to get focus.");
 		return;
 		return;
+	}
 
 
 	get_viewport()->_gui_control_grab_focus(this);
 	get_viewport()->_gui_control_grab_focus(this);
 }
 }