From: Vadim Zeitlin Date: Tue, 15 Nov 2011 15:56:55 +0000 (+0000) Subject: Add support for digits and +/- sign to wxUIActionSimulator::Text(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c0c9009c8d06898324d2f09db1b48423b43faf13?ds=inline Add support for digits and +/- sign to wxUIActionSimulator::Text(). Support the characters needed for number entry in wxUIActionSimulator::Text() too. Closes #13671. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/uiaction.h b/include/wx/uiaction.h index 7736620675..5170170dc9 100644 --- a/include/wx/uiaction.h +++ b/include/wx/uiaction.h @@ -58,8 +58,8 @@ public: { return Key(keycode, modifiers, false); } // Higher level methods for generating both the key press and release for a - // single key or for all characters in the ASCII string "text" which can - // currently contain letters only (no digits, no punctuation). + // single key or for all characters in the ASCII string "text" which can currently + // contain letters, digits and characters for the definition of numbers [+-., ]. bool Char(int keycode, int modifiers = wxMOD_NONE); bool Text(const char *text); diff --git a/interface/wx/uiaction.h b/interface/wx/uiaction.h index 27a707a020..5b038208be 100644 --- a/interface/wx/uiaction.h +++ b/interface/wx/uiaction.h @@ -148,7 +148,8 @@ public: /** Emulate typing in the keys representing the given string. - Currently only the ASCII letters (i.e. characters @c a-z and @c A-Z) + Currently only the ASCII letters, digits and characters for the definition + of numbers (i.e. characters @c a-z @c A-Z @c 0-9 @c + @c - @c . @c , @c 'space') are supported. @param text diff --git a/samples/uiaction/uiaction.cpp b/samples/uiaction/uiaction.cpp index 3b6d078587..926d1ae9e2 100644 --- a/samples/uiaction/uiaction.cpp +++ b/samples/uiaction/uiaction.cpp @@ -184,6 +184,9 @@ void MyFrame::OnRunSimulation(wxCommandEvent& WXUNUSED(event)) sim.Char(WXK_RETURN); sim.Text("aAbBcC"); sim.Char(WXK_RETURN); + sim.Text("1 234.57e-8"); + sim.Char(WXK_RETURN); + } void MyFrame::OnButtonPressed(wxCommandEvent& WXUNUSED(event)) diff --git a/src/common/uiactioncmn.cpp b/src/common/uiactioncmn.cpp index 18dcbb7d82..90c5f4201b 100644 --- a/src/common/uiactioncmn.cpp +++ b/src/common/uiactioncmn.cpp @@ -80,6 +80,51 @@ void wxUIActionSimulator::SimulateModifiers(int modifiers, bool isDown) bool wxUIActionSimulator::Char(int keycode, int modifiers) { + switch(keycode) + { + case '0': + keycode = WXK_NUMPAD0; + break; + case '1': + keycode = WXK_NUMPAD1; + break; + case '2': + keycode = WXK_NUMPAD2; + break; + case '3': + keycode = WXK_NUMPAD3; + break; + case '4': + keycode = WXK_NUMPAD4; + break; + case '5': + keycode = WXK_NUMPAD5; + break; + case '6': + keycode = WXK_NUMPAD6; + break; + case '7': + keycode = WXK_NUMPAD7; + break; + case '8': + keycode = WXK_NUMPAD8; + break; + case '9': + keycode = WXK_NUMPAD9; + break; + case '+': + keycode = WXK_NUMPAD_ADD; + break; + case '-': + keycode = WXK_NUMPAD_SUBTRACT; + break; + case '.': + keycode = WXK_NUMPAD_DECIMAL; + break; + default: + break; + }; + Key(keycode, modifiers, true); Key(keycode, modifiers, false); @@ -91,9 +136,6 @@ bool wxUIActionSimulator::Text(const char *s) while ( *s != '\0' ) { const char ch = *s++; - - wxASSERT_MSG( ch, "Only letters are allowed" ); - if ( !Char(ch, isupper(ch) ? wxMOD_SHIFT : 0) ) return false; }