Add option to display custom context menu in stc sample

This option could be useful to demonstrate ability to replace (override) standard Scintilla context menu with custom one. Switching between standard and custom popup menu is done with "Extra -> Custom popup menu" menu option.
This commit is contained in:
New Pagodi
2017-03-16 23:31:17 +01:00
committed by Artur Wieczorek
parent 6aa5d07229
commit 962979ebf1
4 changed files with 34 additions and 1 deletions

View File

@@ -111,6 +111,7 @@ wxBEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl)
EVT_MENU(myID_MULTIPLE_SELECTIONS, Edit::OnMultipleSelections)
EVT_MENU(myID_MULTI_PASTE, Edit::OnMultiPaste)
EVT_MENU(myID_MULTIPLE_SELECTIONS_TYPING, Edit::OnMultipleSelectionsTyping)
EVT_MENU(myID_CUSTOM_POPUP, Edit::OnCustomPopup)
// stc
EVT_STC_MARGINCLICK (wxID_ANY, Edit::OnMarginClick)
EVT_STC_CHARADDED (wxID_ANY, Edit::OnCharAdded)
@@ -175,7 +176,7 @@ Edit::Edit (wxWindow *parent, wxWindowID id,
m_FoldingMargin = 16;
CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key
SetLayoutCache (wxSTC_CACHE_PAGE);
UsePopUp(wxSTC_POPUP_ALL);
}
Edit::~Edit () {}
@@ -453,6 +454,11 @@ void Edit::OnMultipleSelectionsTyping(wxCommandEvent& WXUNUSED(event)) {
SetAdditionalSelectionTyping(!isSet);
}
void Edit::OnCustomPopup(wxCommandEvent& evt)
{
UsePopUp(evt.IsChecked() ? wxSTC_POPUP_NEVER : wxSTC_POPUP_ALL);
}
//! misc
void Edit::OnMarginClick (wxStyledTextEvent &event) {
if (event.GetMargin() == 2) {