]> git.saurik.com Git - wxWidgets.git/commitdiff
Add Run Script menu option to the sample.
authorSteve Lamerton <steve.lamerton@gmail.com>
Sat, 13 Aug 2011 14:53:46 +0000 (14:53 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Sat, 13 Aug 2011 14:53:46 +0000 (14:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68682 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/web/web.cpp

index 99a275488b3e4a967873a0bcbd603a9c579198cd..dd40a0ca4568cd15be5fd78f0d0ea5386319f415 100644 (file)
@@ -91,6 +91,7 @@ public:
     void OnMode(wxCommandEvent& evt);
     void OnZoomLayout(wxCommandEvent& evt);
     void OnHistory(wxCommandEvent& evt);
+    void OnRunScript(wxCommandEvent& evt);
 
 private:
     wxTextCtrl* m_url;
@@ -236,7 +237,7 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample")
     m_tools_enable_history = m_tools_history_menu->AppendCheckItem(wxID_ANY, _("Enable History"));
     m_tools_history_menu->AppendSeparator();
 
-    wxMenuItem* history = m_tools_menu->AppendSubMenu(m_tools_history_menu, "History");
+    m_tools_menu->AppendSubMenu(m_tools_history_menu, "History");
 
     //Create an editing menu
     wxMenu* editmenu = new wxMenu();
@@ -252,6 +253,8 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample")
     m_tools_menu->AppendSeparator();
     m_tools_menu->AppendSubMenu(editmenu, "Edit");
 
+    wxMenuItem* script =  m_tools_menu->Append(wxID_ANY, _("Run Script"));
+
     //By default we want to handle navigation and new windows
     m_tools_handle_navigation->Check();
     m_tools_handle_new_window->Check();
@@ -322,6 +325,8 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample")
             wxCommandEventHandler(WebFrame::OnRedo),  NULL, this );
     Connect(m_edit_mode->GetId(), wxEVT_COMMAND_MENU_SELECTED,
             wxCommandEventHandler(WebFrame::OnMode),  NULL, this );
+    Connect(script->GetId(), wxEVT_COMMAND_MENU_SELECTED,
+            wxCommandEventHandler(WebFrame::OnRunScript),  NULL, this );
 }
 
 void WebFrame::OnAnimationTimer(wxTimerEvent& WXUNUSED(evt))
@@ -677,6 +682,15 @@ void WebFrame::OnHistory(wxCommandEvent& evt)
     m_browser->LoadHistoryItem(m_histMenuItems[evt.GetId()]);
 }
 
+void WebFrame::OnRunScript(wxCommandEvent& WXUNUSED(evt))
+{
+    wxTextEntryDialog dialog(this, "Enter JavaScript to run.", wxGetTextFromUserPromptStr, "", wxOK|wxCANCEL|wxCENTRE|wxTE_MULTILINE);
+    if(dialog.ShowModal() == wxID_OK)
+    {
+        m_browser->RunScript(dialog.GetValue());
+    }
+}
+
 /**
   * Callback invoked when a loading error occurs
   */