emulate more arrow keys on non msw platforms
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
3c5f62640d
commit
8680646d5c
@ -940,12 +940,47 @@ int wxTextCtrlBase::overflow(int c)
|
||||
|
||||
bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
|
||||
{
|
||||
bool handled = false;
|
||||
// we have a native implementation for Win32 and so don't need this one
|
||||
#ifndef __WIN32__
|
||||
wxChar ch = 0;
|
||||
int keycode = event.GetKeyCode();
|
||||
|
||||
long from, to;
|
||||
GetSelection(&from,&to);
|
||||
long insert = GetInsertionPoint();
|
||||
long last = GetLastPosition();
|
||||
|
||||
// catch arrow left and right
|
||||
|
||||
switch ( keycode )
|
||||
{
|
||||
case WXK_LEFT:
|
||||
if ( event.ShiftDown() )
|
||||
SetSelection( (from > 0 ? from - 1 : 0) , to );
|
||||
else
|
||||
{
|
||||
if ( from != to )
|
||||
insert = from;
|
||||
else if ( insert > 0 )
|
||||
insert -= 1;
|
||||
SetInsertionPoint( insert );
|
||||
}
|
||||
handled = true;
|
||||
break;
|
||||
case WXK_RIGHT:
|
||||
if ( event.ShiftDown() )
|
||||
SetSelection( from, (to < last ? to + 1 : last) );
|
||||
else
|
||||
{
|
||||
if ( from != to )
|
||||
insert = to;
|
||||
else if ( insert < last )
|
||||
insert += 1;
|
||||
SetInsertionPoint( insert );
|
||||
}
|
||||
handled = true;
|
||||
break;
|
||||
case WXK_NUMPAD0:
|
||||
case WXK_NUMPAD1:
|
||||
case WXK_NUMPAD2:
|
||||
@ -991,6 +1026,7 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
|
||||
const long pos = GetInsertionPoint();
|
||||
if ( pos < GetLastPosition() )
|
||||
Remove(pos, pos + 1);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1000,6 +1036,7 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
|
||||
const long pos = GetInsertionPoint();
|
||||
if ( pos > 0 )
|
||||
Remove(pos - 1, pos);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1031,13 +1068,13 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
|
||||
{
|
||||
WriteText(ch);
|
||||
|
||||
return true;
|
||||
handled = true;
|
||||
}
|
||||
#else // __WIN32__
|
||||
wxUnusedVar(event);
|
||||
#endif // !__WIN32__/__WIN32__
|
||||
|
||||
return false;
|
||||
return handled;
|
||||
}
|
||||
|
||||
// do the window-specific processing after processing the update event
|
||||
|
Loading…
Reference in New Issue
Block a user