Re: Popup menu
- Posted by Pete Stoner <stoner.pete at gmail.com> Mar 19, 2007
- 553 views
CChris wrote: > > Pete Stoner wrote: > > > > Hi Guys, > > I have a win32lib prog with a hidden window that opens a popup menu at the > > cursor > > position, there's one last thing I am trying to get working... > > > > Is there a notification I can act on when the menu disappears? i.e. the user > > opens the popup menu then clicks elsewhere on the screen without selecting > > any > > menu item so the menu just 'goes away' and I want to be able to trigger a > > routine > > when this happens, but I haven't been able to find an event notification for > > it. > > > > Regards PeteS > > This works in my modified version, by firing w32HCloseUp on the menu. So far, > I had no signal from Derek on whether he plans to absorb this, and a few > other, change into the official lib. > > A quick fix would be to set a raw message handler for your hidden window > listening for the WM_EXITMENULOOP message. As I understand it, your > window only has one menu, so this could be the way to go. This trick won't > tell you if submenus of your popup menu were closed, only the menu itself. > > CChris Thanks Chris, this works
function PopupClose(integer pSource, atom hWnd, atom iMsg, atom wParam, atom lParam) ? 1 return {0} end function setWinMsgHandler( MainWin, WM_EXITMENULOOP, routine_id("PopupClose"))
It triggers fine when the menu closes, but I just realised the routine I want to run when the menu closes will break the routines that run when an item is clicked (its a 'cleanup' routine which *must* run after any menu item routines have finished). I've tried setting a flag on the menuitem click event and checking that flag in the exitmenuloop routine but it looks like the exitmenuloop is triggered before the click so the flag doesn't work.. What I need is to be able to run the cleanup either if the user clicks elsewhere without selecting a menu item or *after* any menu click routines have finished. Any ideas? Regards PeteS