Using WXK_NUMPADn with wxUIActionSimulator doesn't work under Unix, the
resulting GDK events have wrong keyval for some reason.
It would, of course, be nice to fix this but in the meanwhile use ASCII codes
to simulate the digits to at least allow doing this at all.
Also extend uiaction sample to allow testing text simulation.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69960
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
+ RunSimulation = 1,
+ SimulateText
};
// ----------------------------------------------------------------------------
};
// ----------------------------------------------------------------------------
void OnButtonPressed(wxCommandEvent& event);
void OnRunSimulation(wxCommandEvent& event);
void OnButtonPressed(wxCommandEvent& event);
void OnRunSimulation(wxCommandEvent& event);
+ void OnSimulateText(wxCommandEvent& event);
void OnExit(wxCommandEvent& WXUNUSED(event)) { Close(); }
private:
void OnExit(wxCommandEvent& WXUNUSED(event)) { Close(); }
private:
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_BUTTON(wxID_ANY, MyFrame::OnButtonPressed)
EVT_MENU(RunSimulation, MyFrame::OnRunSimulation)
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_BUTTON(wxID_ANY, MyFrame::OnButtonPressed)
EVT_MENU(RunSimulation, MyFrame::OnRunSimulation)
+ EVT_MENU(SimulateText, MyFrame::OnSimulateText)
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
END_EVENT_TABLE()
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
END_EVENT_TABLE()
wxMenu *fileMenu = new wxMenu;
fileMenu->Append(wxID_NEW, "&New File...", "Open a new file");
wxMenu *fileMenu = new wxMenu;
fileMenu->Append(wxID_NEW, "&New File...", "Open a new file");
- fileMenu->Append(RunSimulation, "&Run Simulation...", "Run the UI action simulation");
+ fileMenu->Append(RunSimulation, "&Run Simulation",
+ "Run predefined UI action simulation");
+ fileMenu->Append(SimulateText, "Simulate &text input...",
+ "Enter text to simulate");
+ fileMenu->AppendSeparator();
fileMenu->Append(wxID_EXIT, "E&xit\tAlt-X", "Quit this program");
fileMenu->Append(wxID_EXIT, "E&xit\tAlt-X", "Quit this program");
+void MyFrame::OnSimulateText(wxCommandEvent& WXUNUSED(event))
+{
+ static wxString s_text;
+ const wxString text = wxGetTextFromUser
+ (
+ "Enter text to simulate: ",
+ "wxUIActionSimulator wxWidgets Sample",
+ s_text,
+ this
+ );
+ if ( text.empty() )
+ return;
+
+ s_text = text;
+
+ wxUIActionSimulator sim;
+ m_text->SetFocus();
+ sim.Text(s_text);
+}
+
void MyFrame::OnButtonPressed(wxCommandEvent& WXUNUSED(event))
{
m_text->AppendText("Button pressed.\n");
void MyFrame::OnButtonPressed(wxCommandEvent& WXUNUSED(event))
{
m_text->AppendText("Button pressed.\n");
switch(keycode)
{
case '0':
switch(keycode)
{
case '0':
- keycode = WXK_NUMPAD_ADD;
- keycode = WXK_NUMPAD_SUBTRACT;
- keycode = WXK_NUMPAD_DECIMAL;