X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6ce832135e0cd665403406e7276630f415a7875b..fb2281054c60ade3dcd7bf26cc896dd4d7451674:/src/common/textcmn.cpp diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index 9e04aedcaa..d64baccfb7 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -773,7 +773,7 @@ bool wxTextAttr::BitlistsEqPartial(int valueA, int valueB, int flags) { int relevantBitsA = valueA & flags; int relevantBitsB = valueB & flags; - return (relevantBitsA != relevantBitsB); + return relevantBitsA == relevantBitsB; } /// Split into paragraph and character styles @@ -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