made generic EmulateKeyPress() to work with Delete and BackSpace (closes bug 658409)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-01-02 00:07:13 +00:00
parent fdd04d720f
commit cd916794f0
3 changed files with 25 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ Unix:
wxGTK: wxGTK:
- fixed wxMenu::Remove (John Skiff and Benjamin Williams) - fixed wxMenu::Remove (John Skiff and Benjamin Williams)
- made wxTextCtrl::EmulateKeyPress() work for Delete and Backspace
wxMSW: wxMSW:
@@ -27,8 +28,7 @@ wxMSW:
All: All:
- Implemented GetEditControl for wxGenericTreeCtrl (Peter - Implemented GetEditControl for wxGenericTreeCtrl (Peter Stieber)
Stieber)
- Improved contrib/utils/convertrc parsing (David J. Cooke) - Improved contrib/utils/convertrc parsing (David J. Cooke)
- Fixed handling of URLs and filenames in wxFileSystem - Fixed handling of URLs and filenames in wxFileSystem
- Implemented alignment for wxGrid bool editor and renderer - Implemented alignment for wxGrid bool editor and renderer

View 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} {\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN}
handler previously by wxWindows. 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} \wxheading{Return value}
{\tt TRUE} if the event resulted in a change to the control, {\tt FALSE} {\tt TRUE} if the event resulted in a change to the control, {\tt FALSE}

View File

@@ -327,6 +327,26 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
ch = _T('/'); ch = _T('/');
break; 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: default:
if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) ) if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) )
{ {