]> git.saurik.com Git - wxWidgets.git/commitdiff
made generic EmulateKeyPress() to work with Delete and BackSpace (closes bug 658409)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 2 Jan 2003 00:07:13 +0000 (00:07 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 2 Jan 2003 00:07:13 +0000 (00:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/text.tex
src/common/textcmn.cpp

index feb0423315960046def61c7a53605fc42b5d5177..38e51842b4bcab307e491ec7f29072d68a0eadd8 100644 (file)
@@ -18,6 +18,7 @@ Unix:
 wxGTK:
 
 - fixed wxMenu::Remove (John Skiff and Benjamin Williams)
+- made wxTextCtrl::EmulateKeyPress() work for Delete and Backspace
 
 wxMSW:
 
@@ -27,8 +28,7 @@ wxMSW:
 
 All:
 
-- Implemented GetEditControl for wxGenericTreeCtrl (Peter
-  Stieber)
+- Implemented GetEditControl for wxGenericTreeCtrl (Peter Stieber)
 - Improved contrib/utils/convertrc parsing (David J. Cooke)
 - Fixed handling of URLs and filenames in wxFileSystem
 - Implemented alignment for wxGrid bool editor and renderer
index 32527801c38eb56fa32cb2ddd5898fde8b6c6549..47d21ad97dd418ef140fb1b6fa8c80043ac51901 100644 (file)
@@ -433,6 +433,9 @@ inserted if the given key event had occured in the text control. The
 {\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN}
 handler previously by wxWindows.
 
+Please note that this function doesn't currently work correctly for all keys
+under any platform but MSW.
+
 \wxheading{Return value}
 
 {\tt TRUE} if the event resulted in a change to the control, {\tt FALSE}
index de9a68979c74aa898759beb12d857ce42d514d2f..c7bb1f7f46205c6996b57c04693e9a66de67bc54 100644 (file)
@@ -327,6 +327,26 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
             ch = _T('/');
             break;
 
+        case WXK_DELETE:
+        case WXK_NUMPAD_DELETE:
+            // delete the character at cursor
+            {
+                const long pos = GetInsertionPoint(),
+                           last = GetLastPosition();
+                if ( pos < last )
+                    Remove(pos, pos + 1);
+            }
+            break;
+
+        case WXK_BACK:
+            // delete the character before the cursor
+            {
+                const long pos = GetInsertionPoint();
+                if ( pos > 0 )
+                    Remove(pos - 1, pos);
+            }
+            break;
+
         default:
             if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) )
             {