Handle EVT_CONTEXT_MENU directly in wxSTC (wxOSX)

A simulation of context menu event by handling directly EVT_RIGHT_UP was implemented in wxSTC in 451c5cc7b9, but later on, EVT_CONTEXT_MENU generation in wxOSX was fixed in 524c47aa3a so  simulation is no longer necessary and this event can be directly handled in wxSTC.
This commit is contained in:
Artur Wieczorek
2017-07-02 13:02:13 +02:00
parent 2971930ab8
commit f311807112
6 changed files with 6 additions and 32 deletions

View File

@@ -5427,7 +5427,6 @@ protected:
void OnMouseRightDown(wxMouseEvent& evt);
void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt);
void OnMouseMiddleUp(wxMouseEvent& evt);
void OnContextMenu(wxContextMenuEvent& evt);
void OnMouseWheel(wxMouseEvent& evt);

View File

@@ -6437,8 +6437,8 @@ public:
@link wxStyledTextCtrl::wxSTC_POPUP_NEVER wxSTC_POPUP_* @endlink constants.
@remarks
When wxContextMenuEvent is used to create a custom popup menu,
this function should be called with wxSTC_POPUP_NEVER. Otherwise both
the custom and the default popup menus may be shown.
this function should be called with wxSTC_POPUP_NEVER. Otherwise
the default menu will be shown instead of the custom one.
*/
void UsePopUp(int popUpMode);

View File

@@ -1282,8 +1282,8 @@ extendedDocs = {
'@link wxStyledTextCtrl::wxSTC_POPUP_NEVER wxSTC_POPUP_* @endlink constants.',
'@remarks',
'When wxContextMenuEvent is used to create a custom popup menu,',
'this function should be called with wxSTC_POPUP_NEVER. Otherwise both',
'the custom and the default popup menus may be shown.',),
'this function should be called with wxSTC_POPUP_NEVER. Otherwise',
'the default menu will be shown instead of the custom one.',),
'PropertyType':
('The return value will be one of the',

View File

@@ -151,11 +151,7 @@ wxBEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
#if defined(__WXMAC__)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
#else
EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
#endif
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
EVT_CHAR (wxStyledTextCtrl::OnChar)
@@ -5211,8 +5207,7 @@ void wxStyledTextCtrl::OnMouseRightDown(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoRightButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
// we need to call evt.Skip() to ensure the context menu event
// is generated with wxOSX
// We need to call evt.Skip() to allow generating EVT_CONTEXT_MENU
evt.Skip();
}
@@ -5227,13 +5222,6 @@ void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
evt.ControlDown());
}
void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));

View File

@@ -151,11 +151,7 @@ wxBEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
#if defined(__WXMAC__)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
#else
EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
#endif
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
EVT_CHAR (wxStyledTextCtrl::OnChar)
@@ -726,8 +722,7 @@ void wxStyledTextCtrl::OnMouseRightDown(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoRightButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
// we need to call evt.Skip() to ensure the context menu event
// is generated with wxOSX
// We need to call evt.Skip() to allow generating EVT_CONTEXT_MENU
evt.Skip();
}
@@ -742,13 +737,6 @@ void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
evt.ControlDown());
}
void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));

View File

@@ -550,7 +550,6 @@ protected:
void OnMouseRightDown(wxMouseEvent& evt);
void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt);
void OnMouseMiddleUp(wxMouseEvent& evt);
void OnContextMenu(wxContextMenuEvent& evt);
void OnMouseWheel(wxMouseEvent& evt);