mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Merge pull request #955 from Areloch/canvasLastInputDeviceTracking
Adds logic so the canvas keeps track of the last input device
This commit is contained in:
commit
7fa2e72d5f
2 changed files with 30 additions and 0 deletions
|
|
@ -180,6 +180,7 @@ GuiCanvas::GuiCanvas(): GuiControl(),
|
||||||
mNumFences = 0;
|
mNumFences = 0;
|
||||||
#endif
|
#endif
|
||||||
mConsumeLastInputEvent = false;
|
mConsumeLastInputEvent = false;
|
||||||
|
mLastInputDeviceType = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiCanvas::~GuiCanvas()
|
GuiCanvas::~GuiCanvas()
|
||||||
|
|
@ -686,6 +687,8 @@ bool GuiCanvas::tabPrev(void)
|
||||||
bool GuiCanvas::processInputEvent(InputEventInfo &inputEvent)
|
bool GuiCanvas::processInputEvent(InputEventInfo &inputEvent)
|
||||||
{
|
{
|
||||||
mConsumeLastInputEvent = true;
|
mConsumeLastInputEvent = true;
|
||||||
|
mLastInputDeviceType = inputEvent.deviceType;
|
||||||
|
|
||||||
// First call the general input handler (on the extremely off-chance that it will be handled):
|
// First call the general input handler (on the extremely off-chance that it will be handled):
|
||||||
if (mFirstResponder && mFirstResponder->onInputEvent(inputEvent))
|
if (mFirstResponder && mFirstResponder->onInputEvent(inputEvent))
|
||||||
{
|
{
|
||||||
|
|
@ -2138,6 +2141,26 @@ void GuiCanvas::setFirstResponder( GuiControl* newResponder )
|
||||||
newResponder->onGainFirstResponder();
|
newResponder->onGainFirstResponder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringTableEntry GuiCanvas::getLastInputDeviceType()
|
||||||
|
{
|
||||||
|
switch (mLastInputDeviceType)
|
||||||
|
{
|
||||||
|
case KeyboardDeviceType:
|
||||||
|
return StringTable->insert("Keyboard");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GamepadDeviceType:
|
||||||
|
return StringTable->insert("Gamepad");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MouseDeviceType:
|
||||||
|
return StringTable->insert("Mouse");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod( GuiCanvas, getContent, S32, (),,
|
DefineEngineMethod( GuiCanvas, getContent, S32, (),,
|
||||||
"@brief Get the GuiControl which is being used as the content.\n\n"
|
"@brief Get the GuiControl which is being used as the content.\n\n"
|
||||||
|
|
||||||
|
|
@ -2954,3 +2977,7 @@ DefineEngineMethod(GuiCanvas, resetVideoMode, void, (), , "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiCanvas, getLastInputDevice, const char*, (), , "Returns the name of the last input device that the GuiCanvas consumed.")
|
||||||
|
{
|
||||||
|
return object->getLastInputDeviceType();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -475,11 +475,14 @@ private:
|
||||||
static const U32 MAX_GAMEPADS = 4; ///< The maximum number of supported gamepads
|
static const U32 MAX_GAMEPADS = 4; ///< The maximum number of supported gamepads
|
||||||
protected:
|
protected:
|
||||||
bool mConsumeLastInputEvent;
|
bool mConsumeLastInputEvent;
|
||||||
|
S32 mLastInputDeviceType;
|
||||||
public:
|
public:
|
||||||
void clearMouseRightButtonDown(void) { mMouseRightButtonDown = false; }
|
void clearMouseRightButtonDown(void) { mMouseRightButtonDown = false; }
|
||||||
void clearMouseButtonDown(void) { mMouseButtonDown = false; }
|
void clearMouseButtonDown(void) { mMouseButtonDown = false; }
|
||||||
void setConsumeLastInputEvent(bool flag) { mConsumeLastInputEvent = flag; }
|
void setConsumeLastInputEvent(bool flag) { mConsumeLastInputEvent = flag; }
|
||||||
bool getLastCursorPoint(Point2I& pt) const { pt = mLastCursorPt; return mLastCursorEnabled; }
|
bool getLastCursorPoint(Point2I& pt) const { pt = mLastCursorPt; return mLastCursorEnabled; }
|
||||||
|
|
||||||
|
StringTableEntry getLastInputDeviceType();
|
||||||
};
|
};
|
||||||
typedef GuiCanvas::KeyTranslationMode KeyboardTranslationMode;
|
typedef GuiCanvas::KeyTranslationMode KeyboardTranslationMode;
|
||||||
DefineEnumType(KeyboardTranslationMode);
|
DefineEnumType(KeyboardTranslationMode);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue