Create WXSendContextMenuEvent() helper function
Put common code from all the different ports into it. This is not very useful right now, but it will allow to change this function once, instead of applying the same change to all ports, in the upcoming commit.
This commit is contained in:
@@ -1513,6 +1513,9 @@ public:
|
||||
// Returns true if more idle time is requested.
|
||||
virtual bool SendIdleEvents(wxIdleEvent& event);
|
||||
|
||||
// Send wxContextMenuEvent and return true if it was processed.
|
||||
bool WXSendContextMenuEvent(const wxPoint& posInScreenCoords);
|
||||
|
||||
// get the handle of the window for the underlying window system: this
|
||||
// is only used for wxWin itself or for user code which wants to call
|
||||
// platform-specific APIs
|
||||
|
@@ -3069,6 +3069,13 @@ wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y)
|
||||
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
bool wxWindowBase::WXSendContextMenuEvent(const wxPoint& posInScreenCoords)
|
||||
{
|
||||
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), posInScreenCoords);
|
||||
evtCtx.SetEventObject(this);
|
||||
return HandleWindowEvent(evtCtx);
|
||||
}
|
||||
|
||||
// methods for drawing the sizers in a visible way: this is currently only
|
||||
// enabled for "full debug" builds with wxDEBUG_LEVEL==2 as it doesn't work
|
||||
// that well and also because we don't want to leave it enabled in default
|
||||
|
@@ -1706,12 +1706,8 @@ gtk_window_button_press_callback( GtkWidget* WXUNUSED_IN_GTK3(widget),
|
||||
// (a) it's a command event and so is propagated to the parent
|
||||
// (b) under some ports it can be generated from kbd too
|
||||
// (c) it uses screen coords (because of (a))
|
||||
wxContextMenuEvent evtCtx(
|
||||
wxEVT_CONTEXT_MENU,
|
||||
win->GetId(),
|
||||
win->ClientToScreen(event.GetPosition()));
|
||||
evtCtx.SetEventObject(win);
|
||||
return win->GTKProcessEvent(evtCtx);
|
||||
const wxPoint pos = win->ClientToScreen(event.GetPosition());
|
||||
return win->WXSendContextMenuEvent(pos);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@@ -1629,12 +1629,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
|
||||
// (a) it's a command event and so is propagated to the parent
|
||||
// (b) under some ports it can be generated from kbd too
|
||||
// (c) it uses screen coords (because of (a))
|
||||
wxContextMenuEvent evtCtx(
|
||||
wxEVT_CONTEXT_MENU,
|
||||
win->GetId(),
|
||||
win->ClientToScreen(event.GetPosition()));
|
||||
evtCtx.SetEventObject(win);
|
||||
return win->HandleWindowEvent(evtCtx);
|
||||
const wxPoint pos = win->ClientToScreen(event.GetPosition());
|
||||
return win->WXSendContextMenuEvent(pos);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@@ -3636,8 +3636,6 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
||||
// the event may be handled by a parent window
|
||||
wxPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
|
||||
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), pt);
|
||||
|
||||
// we could have got an event from our child, reflect it back
|
||||
// to it if this is the case
|
||||
wxWindowMSW *win = NULL;
|
||||
@@ -3650,8 +3648,7 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
||||
if ( !win )
|
||||
win = this;
|
||||
|
||||
evtCtx.SetEventObject(win);
|
||||
processed = win->HandleWindowEvent(evtCtx);
|
||||
processed = win->WXSendContextMenuEvent(pt);
|
||||
|
||||
if ( !processed )
|
||||
{
|
||||
|
@@ -2338,20 +2338,7 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event )
|
||||
{
|
||||
if ( event.GetEventType() == wxEVT_RIGHT_DOWN )
|
||||
{
|
||||
// copied from wxGTK : CS
|
||||
// VZ: shouldn't we move this to base class then?
|
||||
|
||||
// generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
|
||||
// except that:
|
||||
//
|
||||
// (a) it's a command event and so is propagated to the parent
|
||||
// (b) under MSW it can be generated from kbd too
|
||||
// (c) it uses screen coords (because of (a))
|
||||
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
|
||||
this->GetId(),
|
||||
this->ClientToScreen(event.GetPosition()));
|
||||
evtCtx.SetEventObject(this);
|
||||
if ( ! HandleWindowEvent(evtCtx) )
|
||||
if ( !WXSendContextMenuEvent(ClientToScreen(event.GetPosition())) )
|
||||
event.Skip() ;
|
||||
}
|
||||
else
|
||||
|
@@ -1619,15 +1619,11 @@ bool wxWindowQt::QtHandleCloseEvent ( QWidget *handler, QCloseEvent *WXUNUSED( e
|
||||
|
||||
bool wxWindowQt::QtHandleContextMenuEvent ( QWidget *WXUNUSED( handler ), QContextMenuEvent *event )
|
||||
{
|
||||
wxContextMenuEvent e( wxEVT_CONTEXT_MENU, GetId() );
|
||||
e.SetPosition(
|
||||
const wxPoint pos =
|
||||
event->reason() == QContextMenuEvent::Keyboard
|
||||
? wxDefaultPosition
|
||||
: wxQtConvertPoint( event->globalPos() )
|
||||
);
|
||||
e.SetEventObject(this);
|
||||
|
||||
return ProcessWindowEvent( e );
|
||||
: wxQtConvertPoint( event->globalPos() );
|
||||
return WXSendContextMenuEvent(pos);
|
||||
}
|
||||
|
||||
bool wxWindowQt::QtHandleFocusEvent ( QWidget *WXUNUSED( handler ), QFocusEvent *event )
|
||||
|
Reference in New Issue
Block a user