]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix use of DELETE and BACKSPACE when starting editing grid with them.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Oct 2010 17:34:22 +0000 (17:34 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Oct 2010 17:34:22 +0000 (17:34 +0000)
Using the current insertion position in wxGridCellTextEditor::StartingKey()
didn't make much sense, it was always 0 -- so DELETE worked as expected and
did delete the first character of the cell but BACKSPACE never did anything.

Just always delete the first character when DELETE is used and always delete
the last one when BACKSPACE is.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65749 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/grideditors.cpp

index ef818831bbeb512de8f0c5dbe507fbf60f0f578d..d764a71e09c5d66390d79c5d970702940a8560ef 100644 (file)
@@ -548,7 +548,6 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
 
     wxTextCtrl* tc = Text();
     wxChar ch;
-    long pos;
 
     bool isPrintable;
 
@@ -566,17 +565,16 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
     switch (ch)
     {
         case WXK_DELETE:
-            // delete the character at the cursor
-            pos = tc->GetInsertionPoint();
-            if (pos < tc->GetLastPosition())
-                tc->Remove(pos, pos + 1);
+            // Delete the initial character when starting to edit with DELETE.
+            tc->Remove(0, 1);
             break;
 
         case WXK_BACK:
-            // delete the character before the cursor
-            pos = tc->GetInsertionPoint();
-            if (pos > 0)
+            // Delete the last character when starting to edit with BACKSPACE.
+            {
+                const long pos = tc->GetLastPosition();
                 tc->Remove(pos - 1, pos);
+            }
             break;
 
         default: