Example #1
0
void MyFrame::OnShowContextMenu(wxWebEvent& evt)
{
    wxMenu menuPopup;

    wxString href = evt.GetHref();
    if (!href.IsEmpty())
    {
        menuPopup.Append(ID_OpenHref, _("&Open"));
        menuPopup.AppendSeparator();
        m_uri_href = href;
    }
    else
    {
        menuPopup.Append(ID_GoBack, _("&Back"));
        menuPopup.Append(ID_GoForward, _("&Forward"));
        menuPopup.Append(ID_Reload, _("&Reload"));
        menuPopup.Append(ID_Stop, _("&Stop"));
        menuPopup.AppendSeparator();
    }

    menuPopup.Append(ID_Cut, _("Cu&t"));
    menuPopup.Append(ID_Copy, _("&Copy"));
    menuPopup.Append(ID_CopyLink, _("Copy &Link"));
    menuPopup.Append(ID_Paste, _("&Paste"));
    menuPopup.Append(ID_SelectAll, _("Select &All"));

    wxPoint pt_mouse = ::wxGetMousePosition();
    pt_mouse = m_browser->ScreenToClient(pt_mouse);
    PopupMenu(&menuPopup, pt_mouse);
}
Example #2
0
void wxWebPanelBase::PopulatePopupMenu(wxMenu& menuPopup, const wxWebEvent& evt)
{
	using namespace wxwc_util;

	wxString href = evt.GetHref();
    if (!href.IsEmpty())
    {
		static const menu_item_info link_items[] = {
			{ ID_OpenHref, wxTRANSLATE("&Open"), wxART_FOLDER_OPEN },
			{ ID_CopyLink, wxTRANSLATE("Copy &Link"), wxART_COPY },
			{ ID_OpenHrefInDefault, wxTRANSLATE("Open Link in &Default browser") }
		};
        populate_menu(menuPopup, link_items, sizeof(link_items) / sizeof(link_items[0]));
        m_uri_href = href;
    }
    else
    {
        static const menu_item_info navigation_items[] = {
			{ wxID_BACKWARD, NULL, wxART_GO_BACK },
			{ wxID_FORWARD, NULL, wxART_GO_FORWARD },
			{ wxID_REFRESH, wxTRANSLATE("&Reload"), wxART_REDO },
			{ wxID_STOP, wxTRANSLATE("&Stop loading"), wxART_CROSS_MARK },
		};
		populate_menu(menuPopup, navigation_items, sizeof(navigation_items) / sizeof(navigation_items[0]));
        
    }

	static const menu_item_info generic_items[] = {
		{ wxID_SEPARATOR, NULL, NULL },
		{ wxID_CUT, NULL, wxART_CUT },
		{ wxID_COPY, NULL, wxART_COPY },
		
		{ wxID_PASTE, NULL, wxART_PASTE },
		{ wxID_SELECTALL, wxTRANSLATE("Select &All"), NULL },
		{ wxID_SEPARATOR, NULL, NULL },
		{ wxID_ZOOM_IN, wxTRANSLATE("Larger &Text"), wxART_LIST_VIEW },
		{ wxID_ZOOM_OUT, wxTRANSLATE("&Smaller Text"), wxART_REPORT_VIEW },
		{ wxID_ZOOM_100, wxTRANSLATE("&Normal Text"), NULL },
	};

	populate_menu(menuPopup, generic_items, sizeof(generic_items) / sizeof(generic_items[0]));
}