X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0c9009c8d06898324d2f09db1b48423b43faf13..fa699cbaaf217af186cd04dd10d6ec67c8667136:/samples/uiaction/uiaction.cpp diff --git a/samples/uiaction/uiaction.cpp b/samples/uiaction/uiaction.cpp index 926d1ae9e2..6fd518e299 100644 --- a/samples/uiaction/uiaction.cpp +++ b/samples/uiaction/uiaction.cpp @@ -40,7 +40,7 @@ // the application icon (under Windows and OS/2 it is in resources and even // though we could still include the XPM here it would be unused) -#if !defined(__WXMSW__) && !defined(__WXPM__) +#ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" #endif @@ -52,7 +52,8 @@ enum { // menu items - RunSimulation = 1 + RunSimulation = 1, + SimulateText }; // ---------------------------------------------------------------------------- @@ -77,6 +78,7 @@ public: void OnButtonPressed(wxCommandEvent& event); void OnRunSimulation(wxCommandEvent& event); + void OnSimulateText(wxCommandEvent& event); void OnExit(wxCommandEvent& WXUNUSED(event)) { Close(); } private: @@ -89,6 +91,7 @@ private: 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() @@ -137,7 +140,11 @@ MyFrame::MyFrame(const wxString& title) 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"); @@ -189,6 +196,26 @@ void MyFrame::OnRunSimulation(wxCommandEvent& WXUNUSED(event)) } +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.c_str()); +} + void MyFrame::OnButtonPressed(wxCommandEvent& WXUNUSED(event)) { m_text->AppendText("Button pressed.\n");