Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- gui/controls/guiMLTextEditCtrl.cpp Mon Jan 19 19:26:36 1970
- +++ gui/controls/guiMLTextEditCtrl.cpp Mon Jan 19 19:26:36 1970
- @@ -434,6 +434,46 @@
- ensureCursorOnScreen();
- }
- +bool GuiMLTextEditCtrl::onChar(const GuiEvent &event)
- +{
- + if ( (mFont && mFont->isValidChar(event.ascii)) || (!mFont && event.ascii != 0) )
- + {
- + // Normal ascii keypress. Go ahead and add the chars...
- + if (mSelectionActive == true)
- + {
- + mSelectionActive = false;
- + deleteChars(mSelectionStart, mSelectionEnd);
- + mCursorPosition = mSelectionStart;
- + }
- +
- + UTF8 *outString = NULL;
- + U32 outStringLen = 0;
- +
- +#ifdef TORQUE_UNICODE
- +
- + UTF16 inData[2] = { event.ascii, 0 };
- + StringBuffer inBuff(inData);
- +
- + FrameTemp<UTF8> outBuff(4);
- + inBuff.getCopy8(outBuff, 4);
- +
- + outString = outBuff;
- + outStringLen = inBuff.length();
- +#else
- + char ascii = char(event.ascii);
- + outString = &ascii;
- + outStringLen = 1;
- +#endif
- +
- + insertChars(outString, outStringLen, mCursorPosition);
- + mVertMoveAnchorValid = false;
- + return true;
- + }
- +
- + // Otherwise, let the parent have the event...
- + return Parent::onChar(event);
- +}
- +
- //--------------------------------------------------------------------------
- void GuiMLTextEditCtrl::onRender(Point2I offset, const RectI& updateRect)
- {
- --- gui/controls/guiMLTextEditCtrl.h Mon Jan 19 19:26:36 1970
- +++ gui/controls/guiMLTextEditCtrl.h Mon Jan 19 19:26:36 1970
- @@ -20,6 +20,7 @@
- // Events
- bool onKeyDown(const GuiEvent&event);
- + bool onChar(const GuiEvent &event);
- // Event forwards
- void handleMoveKeys(const GuiEvent&);
- --- gui/controls/guiTextEditCtrl.cpp Mon Jan 19 19:26:36 1970
- +++ gui/controls/guiTextEditCtrl.cpp Mon Jan 19 19:26:36 1970
- @@ -1576,6 +1576,16 @@
- execConsoleCallback();
- }
- +bool GuiTextEditCtrl::onChar(const GuiEvent &event)
- +{
- + if ( mProfile->mFont->isValidChar( event.ascii ) )
- + {
- + handleCharInput( event.ascii );
- + return true;
- + }
- + return Parent::onChar( event );
- +}
- +
- S32 GuiTextEditCtrl::findPrevWord()
- {
- // First the first word to the left of the current cursor position
- --- gui/controls/guiTextEditCtrl.h Mon Jan 19 19:26:36 1970
- +++ gui/controls/guiTextEditCtrl.h Mon Jan 19 19:26:36 1970
- @@ -114,6 +114,7 @@
- void setSinkAllKeys(bool state) { mSinkAllKeyEvents = state; }
- virtual bool onKeyDown(const GuiEvent &event);
- + virtual bool onChar(const GuiEvent &event);
- virtual void onMouseDown(const GuiEvent &event);
- virtual void onMouseDragged(const GuiEvent &event);
- virtual void onMouseUp(const GuiEvent &event);
- --- gui/core/guiCanvas.cpp Mon Jan 19 19:26:36 1970
- +++ gui/core/guiCanvas.cpp Mon Jan 19 19:26:36 1970
- @@ -632,6 +632,11 @@
- return mFirstResponder->onKeyRepeat(mLastEvent);
- }
- }
- + else if(inputEvent.action == SI_CHAR)
- + {
- + if(mFirstResponder)
- + return mFirstResponder->onChar(mLastEvent);
- + }
- return false;
- }
- --- gui/core/guiControl.cpp Mon Jan 19 19:26:36 1970
- +++ gui/core/guiControl.cpp Mon Jan 19 19:26:36 1970
- @@ -922,6 +922,18 @@
- //-----------------------------------------------------------------------------
- +bool GuiControl::onChar(const GuiEvent &event)
- +{
- + //pass the event to the parent
- + GuiControl *parent = getParent();
- + if (parent)
- + return parent->onChar(event);
- + else
- + return false;
- +}
- +
- +//-----------------------------------------------------------------------------
- +
- bool GuiControl::onKeyUp(const GuiEvent &event)
- {
- //pass the event to the parent
- --- gui/core/guiControl.h Mon Jan 19 19:26:36 1970
- +++ gui/core/guiControl.h Mon Jan 19 19:26:36 1970
- @@ -741,6 +741,10 @@
- /// Happens when a key is held down, resulting in repeated keystrokes.
- /// @param event Event descriptor (which contains the key)
- virtual bool onKeyRepeat(const GuiEvent &event);
- +
- + /// Happens when a character is typed
- + /// @param event Event descriptor (which contains the character)
- + virtual bool onChar(const GuiEvent &event);
- /// @}
- /// Return the delegate used to render tooltips on this control.
- --- platform/event.h Mon Jan 19 19:26:36 1970
- +++ platform/event.h Mon Jan 19 19:26:36 1970
- @@ -262,6 +262,9 @@
- /// A key repeat occurred. Happens in between a SI_MAKE and SI_BREAK.
- SI_REPEAT = 0x04,
- +
- + /// Character input event
- + SI_CHAR = 0x05,
- };
- ///Device Event Types
- --- windowManager/win32/win32Window.cpp Mon Jan 19 19:26:36 1970
- +++ windowManager/win32/win32Window.cpp Mon Jan 19 19:26:36 1970
- @@ -857,6 +857,7 @@
- case WM_KEYDOWN:
- case WM_SYSKEYUP:
- case WM_SYSKEYDOWN:
- + case WM_CHAR:
- Dispatch(DelayedDispatch,hWnd,message,wParam,lParam);
- return 0;
- }
- --- windowManager/win32/winDispatch.cpp Mon Jan 19 19:26:36 1970
- +++ windowManager/win32/winDispatch.cpp Mon Jan 19 19:26:36 1970
- @@ -115,6 +115,7 @@
- // mapped in the global action map, try converting the event into
- // a character event first.
- + /*
- if( make
- && window->getKeyboardTranslation()
- && !window->shouldNotTranslate( torqueMods, newVirtKey ) )
- @@ -144,6 +145,7 @@
- return;
- }
- }
- + */
- // Produce a key event.
- @@ -151,6 +153,12 @@
- window->keyEvent.trigger(window->getWindowId(),_ModifierKeys,action,newVirtKey);
- }
- +static void _characterEvent(Win32Window* window,UINT message, WPARAM wParam, WPARAM lParam)
- +{
- + if (wParam >= 32)
- + window->charEvent.trigger(window->getWindowId(),0,wParam);
- +}
- +
- //-----------------------------------------------------------------------------
- @@ -314,6 +322,11 @@
- if (window)
- _keyboardEvent(window,message,wParam,lParam);
- break;
- +
- + case WM_CHAR:
- + if (window)
- + _characterEvent(window,message,wParam,lParam);
- + break;
- // NOTE: if wParam is NOT equal to our window handle then we are GAINING focus
- case WM_SETFOCUS:
- --- windowManager/windowInputGenerator.cpp Mon Jan 19 19:26:36 1970
- +++ windowManager/windowInputGenerator.cpp Mon Jan 19 19:26:36 1970
- @@ -241,13 +241,15 @@
- event.objInst = KEY_NULL;
- event.modifier = convertModifierBits(modifier);
- event.ascii = key;
- - event.action = SI_MAKE;
- + event.action = SI_CHAR; //event.action = SI_MAKE;
- event.fValue = 1.0;
- generateInputEvent(event);
- + /*
- event.action = SI_BREAK;
- event.fValue = 0.f;
- generateInputEvent(event);
- + */
- }
Advertisement
RAW Paste Data
Copied
Advertisement