Ver Fonte

Console Lose First Responder

Modified the console text edit box so that it doesn't run its contents when it loses focus. Typically the console only loses focus after it's closed. It's not good for it to be running code unexpectedly when you can't see it.
Peter Robinson há 3 anos atrás
pai
commit
7e7cf0e5aa

+ 19 - 0
engine/source/gui/guiConsoleEditCtrl.cc

@@ -177,4 +177,23 @@ bool GuiConsoleEditCtrl::handleDelete()
     return result;
     return result;
 }
 }
 
 
+void GuiConsoleEditCtrl::onLoseFirstResponder()
+{
+    Platform::disableKeyboardTranslation();
+
+    if (isMethod("onLoseFirstResponder"))
+        Con::executef(this, 2, "onLoseFirstResponder");
+
+    mSelector.setFirstResponder(false);
+    mTextOffsetY = 0;
+    mScrollVelocity = 0;
+    if (!mTextWrap && mTextBlockList.size() > 0)
+    {
+        mTextBlockList.front().resetScroll();
+    }
+
+    // Redraw the control:
+    setUpdate();
+}
+
 
 

+ 1 - 0
engine/source/gui/guiConsoleEditCtrl.h

@@ -72,6 +72,7 @@ public:
    static void initPersistFields();
    static void initPersistFields();
 
 
    bool onKeyDown(const GuiEvent &event);
    bool onKeyDown(const GuiEvent &event);
+   void onLoseFirstResponder();
 };
 };
 
 
 #endif //_GUI_TEXTEDIT_CTRL_H
 #endif //_GUI_TEXTEDIT_CTRL_H