diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index 493fefc2a9..7b9e1e565e 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -160,6 +160,12 @@ public: wxCursor GetURLCursor() const { return m_urlCursor; } #endif +#if wxABI_VERSION >= 20811 + /// Get/set context menu + wxMenu* GetContextMenu() const { return m_contextMenu; } + void SetContextMenu(wxMenu* menu); +#endif + // Operations // editing diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 835f2307d4..2d02453b18 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -297,6 +297,17 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va wxAcceleratorTable accel(6, entries); SetAcceleratorTable(accel); + m_contextMenu = new wxMenu; + m_contextMenu->Append(wxID_UNDO, _("&Undo")); + m_contextMenu->Append(wxID_REDO, _("&Redo")); + m_contextMenu->AppendSeparator(); + m_contextMenu->Append(wxID_CUT, _("Cu&t")); + m_contextMenu->Append(wxID_COPY, _("&Copy")); + m_contextMenu->Append(wxID_PASTE, _("&Paste")); + m_contextMenu->Append(wxID_CLEAR, _("&Delete")); + m_contextMenu->AppendSeparator(); + m_contextMenu->Append(wxID_SELECTALL, _("Select &All")); + return true; } @@ -2505,6 +2516,13 @@ bool wxRichTextCtrl::CanDeleteSelection() const // Accessors // ---------------------------------------------------------------------------- +void wxRichTextCtrl::SetContextMenu(wxMenu* menu) +{ + if (m_contextMenu && m_contextMenu != menu) + delete m_contextMenu; + m_contextMenu = menu; +} + void wxRichTextCtrl::SetEditable(bool editable) { m_editable = editable; @@ -2809,20 +2827,8 @@ void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event) return; } - if (!m_contextMenu) - { - m_contextMenu = new wxMenu; - m_contextMenu->Append(wxID_UNDO, _("&Undo")); - m_contextMenu->Append(wxID_REDO, _("&Redo")); - m_contextMenu->AppendSeparator(); - m_contextMenu->Append(wxID_CUT, _("Cu&t")); - m_contextMenu->Append(wxID_COPY, _("&Copy")); - m_contextMenu->Append(wxID_PASTE, _("&Paste")); - m_contextMenu->Append(wxID_CLEAR, _("&Delete")); - m_contextMenu->AppendSeparator(); - m_contextMenu->Append(wxID_SELECTALL, _("Select &All")); - } - PopupMenu(m_contextMenu); + if (m_contextMenu) + PopupMenu(m_contextMenu); return; } diff --git a/version-script.in b/version-script.in index 5a3fc118de..3fcc2cce48 100644 --- a/version-script.in +++ b/version-script.in @@ -27,9 +27,11 @@ @WX_VERSION_TAG@.11 { *wxDC*SetDeviceClippingRegion*; *wxGraphicsContext*GetCairoRenderer*; + *wxIconizeEvent*IsIconized*; + *wxRichTextCtrl*GetContextMenu*; + *wxRichTextCtrl*SetContextMenu*; *wxShowEvent*IsShown*; *wxSound*Create*; - *wxIconizeEvent*IsIconized*; *wxXmlNode*Attribute*; };