added wxWindow::GetPopupMenuSelectionFromUser() (modified patch 1793823)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48913 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-09-23 23:42:31 +00:00
parent ab171e9502
commit 00a77b7c5d
5 changed files with 125 additions and 15 deletions

View File

@@ -2233,6 +2233,47 @@ void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
UpdateWindowUI(wxUPDATE_UI_RECURSE);
}
// ----------------------------------------------------------------------------
// menu-related functions
// ----------------------------------------------------------------------------
#if wxUSE_MENUS
// this is used to pass the id of the selected item from the menu event handler
// to the main function itself
//
// it's ok to use a global here as there can be at most one popup menu shown at
// any time
static int gs_popupMenuSelection = wxID_NONE;
void wxWindowBase::InternalOnPopupMenu(wxCommandEvent& event)
{
// store the id in a global variable where we'll retrieve it from later
gs_popupMenuSelection = event.GetId();
}
int
wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y)
{
gs_popupMenuSelection = wxID_NONE;
Connect(wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu),
NULL,
this);
PopupMenu(&menu, x, y);
Disconnect(wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu),
NULL,
this);
return gs_popupMenuSelection;
}
#endif // wxUSE_MENUS
// methods for drawing the sizers in a visible way
#ifdef __WXDEBUG__