- 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:
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
// 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; }
// 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;
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;
// 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
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);
#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:
}
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
DoHandleMenuEvent( wxevent );
}
-void wxMenu::HandleMenuOpened()
+void wxMenu::DoHandleMenuOpenedOrClosed(wxEventType evtType)
{
- wxMenuEvent wxevent(wxEVT_MENU_OPEN, 0, this);
+ // 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()
+{
+ 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)