Danbias/Code/Misc/Input/Source/Win32/Win32ApplicationKeyboard.cpp

52 lines
1.2 KiB
C++
Raw Normal View History

2014-02-20 13:27:21 +01:00
#include "../../Include/Win32/Win32ApplicationKeyboard.h"
#include "Utilities.h"
2014-02-20 13:27:21 +01:00
using namespace ::Input;
using namespace ::Utility::Value;
using ::std::wstring;
2014-02-20 13:27:21 +01:00
Win32ApplicationKeyboard::Win32ApplicationKeyboard() : ApplicationKeyboard() { /* DO nothing */ }
2014-02-20 13:27:21 +01:00
Win32ApplicationKeyboard::~Win32ApplicationKeyboard() { /* DO nothing */ }
void Win32ApplicationKeyboard::CaptureText( UINT msg, WPARAM param )
{
if( !this->textTarget | !this->isEnabled )
return;
switch( msg )
{
case WM_CHAR:
this->textTarget->insert( this->writePos, 1, (wchar_t)param );
++this->writePos;
break;
case WM_KEYDOWN:
{
switch( param )
{
case VK_BACK:
if( this->writePos > 0 )
{
--this->writePos;
this->textTarget->erase( this->writePos, 1 );
}
break;
case VK_DELETE:
if( this->writePos < this->textTarget->size() )
{
this->textTarget->erase( this->writePos, 1 );
}
break;
case VK_LEFT:
this->writePos = Max( this->writePos - 1, (wstring::size_type)0 );
break;
case VK_RIGHT:
this->writePos = Min( this->writePos + 1, this->textTarget->size() );
break;
default: break;
}
}
default: break;
}
}