Browse Source

Filter WM_CHAR messages with control characters. Fix multiline edit input for keyboard layouts using alt key

Bartek Bok 13 years ago
parent
commit
5bd22e1912
  1. 10
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp
  2. 12
      Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp
  3. 2
      Sources/Plasma/PubUtilLib/plInputCore/plInputManager.h

10
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIMultiLineEditCtrl.cpp

@ -1035,9 +1035,6 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyPress( wchar_t key, uint8_t modifiers )
if ((fPrevCtrl || fNextCtrl) && (fLineStarts.GetCount() <= GetFirstVisibleLine())) if ((fPrevCtrl || fNextCtrl) && (fLineStarts.GetCount() <= GetFirstVisibleLine()))
return true; // we're ignoring if we can't actually edit our visible frame (and we're linked) return true; // we're ignoring if we can't actually edit our visible frame (and we're linked)
if (modifiers & pfGameGUIMgr::kCtrlDown)
return true; // we're ignoring ctrl key events
if( fIgnoreNextKey ) if( fIgnoreNextKey )
{ {
// So we don't process keys that already got handled by HandleKeyEvent() // So we don't process keys that already got handled by HandleKeyEvent()
@ -1111,6 +1108,13 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyEvent( pfGameGUIMgr::EventType event, p
return true; return true;
DeleteChar(); DeleteChar();
}
else if( key == KEY_ENTER )
{
if( IsLocked() )
return true;
InsertChar('\n');
} }
else if( key == KEY_ESCAPE ) else if( key == KEY_ESCAPE )
{ {

12
Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp

@ -119,7 +119,8 @@ plInputManager* plInputManager::fInstance = nil;
plInputManager::plInputManager( hsWindowHndl hWnd ) : plInputManager::plInputManager( hsWindowHndl hWnd ) :
fDInputMgr(nil), fDInputMgr(nil),
fInterfaceMgr(nil) fInterfaceMgr(nil),
localeC("C")
{ {
fhWnd = hWnd; fhWnd = hWnd;
fInstance = this; fInstance = this;
@ -289,9 +290,11 @@ void plInputManager::HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM
break; break;
case CHAR_MSG: case CHAR_MSG:
{ {
wchar_t ch = (wchar_t)Wparam;
// These are handled by KEYUP/KEYDOWN and should not be sent // These are handled by KEYUP/KEYDOWN and should not be sent
// We don't like garbage getting in string fields // We don't like garbage getting in string fields
if (Wparam == KEY_BACKSPACE || Wparam == KEY_ESCAPE) if (std::iscntrl(ch, localeC))
break; break;
BYTE scan = (BYTE)(Lparam >> 16); BYTE scan = (BYTE)(Lparam >> 16);
@ -300,10 +303,7 @@ void plInputManager::HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM
bExtended = Lparam >> 24 & 1; bExtended = Lparam >> 24 & 1;
hsBool bRepeat = ((Lparam >> 29) & 0xf) != 0; hsBool bRepeat = ((Lparam >> 29) & 0xf) != 0;
bool down = !(Lparam >> 31); bool down = !(Lparam >> 31);
wchar_t ch = (wchar_t)Wparam;
// for the return key, Windows sends CR, but multiline text input fields want LF (CR is rendered as a wide horizontal space)
if (ch == 0x0D)
ch = 0x0A;
for (int i=0; i<fInputDevices.Count(); i++) for (int i=0; i<fInputDevices.Count(); i++)
fInputDevices[i]->HandleKeyEvent( CHAR_MSG, (plKeyDef)vkey, down, bRepeat, ch ); fInputDevices[i]->HandleKeyEvent( CHAR_MSG, (plKeyDef)vkey, down, bRepeat, ch );
} }

2
Sources/Plasma/PubUtilLib/plInputCore/plInputManager.h

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTemplates.h" #include "hsTemplates.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"
#include "pnInputCore/plInputMap.h" #include "pnInputCore/plInputMap.h"
#include <locale>
class plDInputMgr; class plDInputMgr;
class plInputDevice; class plInputDevice;
@ -99,6 +100,7 @@ protected:
float fMouseScale; float fMouseScale;
static uint8_t bRecenterMouse; static uint8_t bRecenterMouse;
static hsWindowHndl fhWnd; static hsWindowHndl fhWnd;
std::locale localeC;
public: public:
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32

Loading…
Cancel
Save