Add Run Script menu option to the sample.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68682 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -91,6 +91,7 @@ public:
|
|||||||
void OnMode(wxCommandEvent& evt);
|
void OnMode(wxCommandEvent& evt);
|
||||||
void OnZoomLayout(wxCommandEvent& evt);
|
void OnZoomLayout(wxCommandEvent& evt);
|
||||||
void OnHistory(wxCommandEvent& evt);
|
void OnHistory(wxCommandEvent& evt);
|
||||||
|
void OnRunScript(wxCommandEvent& evt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxTextCtrl* m_url;
|
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_enable_history = m_tools_history_menu->AppendCheckItem(wxID_ANY, _("Enable History"));
|
||||||
m_tools_history_menu->AppendSeparator();
|
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
|
//Create an editing menu
|
||||||
wxMenu* editmenu = new wxMenu();
|
wxMenu* editmenu = new wxMenu();
|
||||||
@@ -252,6 +253,8 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample")
|
|||||||
m_tools_menu->AppendSeparator();
|
m_tools_menu->AppendSeparator();
|
||||||
m_tools_menu->AppendSubMenu(editmenu, "Edit");
|
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
|
//By default we want to handle navigation and new windows
|
||||||
m_tools_handle_navigation->Check();
|
m_tools_handle_navigation->Check();
|
||||||
m_tools_handle_new_window->Check();
|
m_tools_handle_new_window->Check();
|
||||||
@@ -322,6 +325,8 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample")
|
|||||||
wxCommandEventHandler(WebFrame::OnRedo), NULL, this );
|
wxCommandEventHandler(WebFrame::OnRedo), NULL, this );
|
||||||
Connect(m_edit_mode->GetId(), wxEVT_COMMAND_MENU_SELECTED,
|
Connect(m_edit_mode->GetId(), wxEVT_COMMAND_MENU_SELECTED,
|
||||||
wxCommandEventHandler(WebFrame::OnMode), NULL, this );
|
wxCommandEventHandler(WebFrame::OnMode), NULL, this );
|
||||||
|
Connect(script->GetId(), wxEVT_COMMAND_MENU_SELECTED,
|
||||||
|
wxCommandEventHandler(WebFrame::OnRunScript), NULL, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::OnAnimationTimer(wxTimerEvent& WXUNUSED(evt))
|
void WebFrame::OnAnimationTimer(wxTimerEvent& WXUNUSED(evt))
|
||||||
@@ -677,6 +682,15 @@ void WebFrame::OnHistory(wxCommandEvent& evt)
|
|||||||
m_browser->LoadHistoryItem(m_histMenuItems[evt.GetId()]);
|
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
|
* Callback invoked when a loading error occurs
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user