Complete wxEVT_MENU_{OPEN,CLOSE} implementation in wxMSW and wxOSX.
Set the wxMenu correctly for wxEVT_MENU_CLOSE events in wxMSW. Set the menu id correctly to allow wxMenuEvent::IsPopup() to work for both wxEVT_MENU_OPEN and wxEVT_MENU_CLOSE in wxOSX. Closes #11313. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70151 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
c2cd367f7d
commit
7f3f059ac5
@ -468,6 +468,7 @@ MSW:
|
||||
|
||||
- Fixed regression with initial focus in the dialogs in 2.9.3.
|
||||
- Added support for wxEXEC_MAKE_GROUP_LEADER to wxExecute (tteras).
|
||||
- Set wxMenu being closed in wxEVT_MENU_CLOSE events (Marcin Malich).
|
||||
|
||||
OSX:
|
||||
|
||||
|
@ -79,7 +79,6 @@ public:
|
||||
bool HandleSize(int x, int y, WXUINT flag);
|
||||
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
|
||||
bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu);
|
||||
bool HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup);
|
||||
|
||||
// tooltip management
|
||||
#if wxUSE_TOOLTIPS
|
||||
@ -133,8 +132,8 @@ protected:
|
||||
// wxMDIChildFrame
|
||||
bool MSWDoTranslateMessage(wxFrame *frame, WXMSG *msg);
|
||||
|
||||
// handle WM_INITMENUPOPUP message to generate wxEVT_MENU_OPEN
|
||||
bool HandleInitMenuPopup(WXHMENU hMenu);
|
||||
// handle WM_(UN)INITMENUPOPUP message to generate wxEVT_MENU_OPEN/CLOSE
|
||||
bool HandleMenuPopup(wxEventType evtType, WXHMENU hMenu);
|
||||
|
||||
virtual bool IsMDIChild() const { return false; }
|
||||
|
||||
|
@ -83,6 +83,10 @@ private:
|
||||
// terminate the current radio group, if any
|
||||
void EndRadioGroup();
|
||||
|
||||
// Common part of HandleMenu{Opened,Closed}().
|
||||
void DoHandleMenuOpenedOrClosed(wxEventType evtType);
|
||||
|
||||
|
||||
// if TRUE, insert a breal before appending the next item
|
||||
bool m_doBreak;
|
||||
|
||||
|
@ -3870,9 +3870,12 @@ public:
|
||||
wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0, wxMenu* menu = NULL);
|
||||
|
||||
/**
|
||||
Returns the menu which is being opened or closed. This method should only be
|
||||
used with the @c OPEN and @c CLOSE events and even for them the
|
||||
returned pointer may be @NULL in some ports.
|
||||
Returns the menu which is being opened or closed.
|
||||
|
||||
This method can only be used with the @c OPEN and @c CLOSE events.
|
||||
|
||||
The returned value is never @NULL in the ports implementing this
|
||||
function, which currently includes all the major ones.
|
||||
*/
|
||||
wxMenu* GetMenu() const;
|
||||
|
||||
|
@ -61,9 +61,9 @@
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_MENUS_NATIVE
|
||||
#if wxUSE_MENUS || wxUSE_MENUS_NATIVE
|
||||
extern wxMenu *wxCurrentPopupMenu;
|
||||
#endif // wxUSE_MENUS_NATIVE
|
||||
#endif // wxUSE_MENUS || wxUSE_MENUS_NATIVE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables
|
||||
@ -849,25 +849,24 @@ wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU WXUNUSED(hMenu))
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup)
|
||||
bool wxFrame::HandleMenuPopup(wxEventType evtType, WXHMENU hMenu)
|
||||
{
|
||||
// we don't have the menu id here, so we use the id to specify if the event
|
||||
// was from a popup menu or a normal one
|
||||
wxMenuEvent event(evtType, isPopup ? -1 : 0);
|
||||
event.SetEventObject(this);
|
||||
|
||||
return HandleWindowEvent(event);
|
||||
}
|
||||
|
||||
bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu)
|
||||
{
|
||||
int menuid = 0;
|
||||
wxMenu* menu = NULL;
|
||||
if (GetMenuBar())
|
||||
{
|
||||
menu = GetMenuBar()->MSWGetMenu(hMenu);
|
||||
}
|
||||
else if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetHMenu() == hMenu )
|
||||
{
|
||||
menu = wxCurrentPopupMenu;
|
||||
menuid = wxID_ANY;
|
||||
}
|
||||
|
||||
wxMenuEvent event(wxEVT_MENU_OPEN, 0, menu);
|
||||
wxMenuEvent event(evtType, menuid, menu);
|
||||
event.SetEventObject(this);
|
||||
|
||||
return HandleWindowEvent(event);
|
||||
@ -917,7 +916,7 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara
|
||||
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
|
||||
#if wxUSE_MENUS
|
||||
case WM_INITMENUPOPUP:
|
||||
processed = HandleInitMenuPopup((WXHMENU) wParam);
|
||||
processed = HandleMenuPopup(wxEVT_MENU_OPEN, (WXHMENU)wParam);
|
||||
break;
|
||||
|
||||
case WM_MENUSELECT:
|
||||
@ -930,8 +929,8 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_EXITMENULOOP:
|
||||
processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam);
|
||||
case WM_UNINITMENUPOPUP:
|
||||
processed = HandleMenuPopup(wxEVT_MENU_CLOSE, (WXHMENU)wParam);
|
||||
break;
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
|
@ -452,16 +452,25 @@ void wxMenu::HandleMenuItemHighlighted( wxMenuItem* item )
|
||||
DoHandleMenuEvent( wxevent );
|
||||
}
|
||||
|
||||
void wxMenu::DoHandleMenuOpenedOrClosed(wxEventType evtType)
|
||||
{
|
||||
// Popup menu being currently shown or NULL, defined in wincmn.cpp.
|
||||
extern wxMenu *wxCurrentPopupMenu;
|
||||
|
||||
// Set the id to allow wxMenuEvent::IsPopup() to work correctly.
|
||||
int menuid = this == wxCurrentPopupMenu ? wxID_ANY : 0;
|
||||
wxMenuEvent wxevent(evtType, menuid, this);
|
||||
DoHandleMenuEvent( wxevent );
|
||||
}
|
||||
|
||||
void wxMenu::HandleMenuOpened()
|
||||
{
|
||||
wxMenuEvent wxevent(wxEVT_MENU_OPEN, 0, this);
|
||||
DoHandleMenuEvent( wxevent );
|
||||
DoHandleMenuOpenedOrClosed(wxEVT_MENU_OPEN);
|
||||
}
|
||||
|
||||
void wxMenu::HandleMenuClosed()
|
||||
{
|
||||
wxMenuEvent wxevent(wxEVT_MENU_CLOSE, 0, this);
|
||||
DoHandleMenuEvent( wxevent );
|
||||
DoHandleMenuOpenedOrClosed(wxEVT_MENU_CLOSE);
|
||||
}
|
||||
|
||||
bool wxMenu::DoHandleMenuEvent(wxEvent& wxevent)
|
||||
|
Loading…
Reference in New Issue
Block a user