Popupmenu: How to check if it's open n. close it?
BlitzMax Forums/MaxGUI Module/Popupmenu: How to check if it's open n. close it?
| ||
Hi! In my app I have a taskbaricon that brings up a popupmenu when you mouseclick(2) on it. -> "PopupWindowMenu MainWindow, popmenu" How can I check if the menu is already open, so I can close it when the user reclicks the icon without making a selection from the menu itself. It seems like all events are halted once the popupmenu is up??? Already tried: ActiveGadget() = popmenum doesn't work GadgetHidden(popmenu),fails FreeMenu (PopMenu), fails -> though I just want to hide it anyway. Must be missing something... Grisu |
| ||
The popupmenu is automatically closed when you select an entry or click elsewhere (outside the popupmenu). Why would you want to close it manually? When the user clicks outside the popupmenu but again on the icon it should close on left click or reopen on the new position on right click. I see nothing you have to do?! Maybe I didn't understand the problem. |
| ||
^^ just what jsp said |
| ||
Please download: http://knot.eu5.org/prp_win32.zip 1. After startup, minimize the window 2. Right click on the taskbar icon (which brings up the popmenu) 3. Left click "outside" of the menu should close it, but it doesn't. Hope that makes things clearer... |
| ||
Hmm, I see what you mean, but I think the problem is more with the tray routine together with the popup. When you look at any other popupmenu you use, it works like it should. It seams that the popupmenu does not realize that there is an event from the outside and thus don't close. Does the tray routine have it's own event queue? |
| ||
yes |
| ||
You mixed here two things, the message system and the event system and that's probably the problem. The popupmenu is shown when the right message was filtered, but there will be no events. I could may imagine two ways to overcome this. First instead of calling the popupmenu directly you could also use PostGuiEvent and jump back into your normal event queue and handle that, or second you call a function which hooks itself in the event queue and handle the popup there. |
| ||
Well, I have changed the function above to get back to the normal eventqueue. Case WM_RBUTTONDOWN PostGuiEvent( EVENT_MOUSEDOWN, owner, MOUSE_RIGHT ) Even now, the popup menu stays open. So I guess it's the core function that automatically closes the popmenu which is broken. What kind of event is triggered when the popmenu gets a close call? I probably need to post that event back too. |
| ||
I think any event outside the popup should close it, can't say why it doesn't work here. |
| ||
Quick example. All you need is an icon object file for it, that will be used as trayicon. |
| ||
I looked at your code, but it does not work as one would expect. Even the abstraction via an extra event does not help, the only thing I realized was that when you don't hide the window and click on it, the popupmenu goes away. That looks to me, that the popupmenu needs the surrounding of the parent window it was attached to and as it's not available when sitting in the tray it got stuck (just a guess). Maybe you have to parent the popupmenu to the taskbar where it sits in, to function correctly. |
| ||
Just came home from work. Thanks a lot for looking into this! I don't know how to parent the popupmenu to the taskbar. Perhaps the Seb can implement a fix for that... |
| ||
I had this problem a few years ago when writing some VB6 apps. Could it be because by clicking on anything other than the blitz app window, the blitz app has essentially lost focus so doesn't receive events? Don't think I ever found a way round it with VB6, so be interesting to see if there is a solution. |
| ||
Thats exactly the problem, there are no more events when the popup is open from the tray. When open as popupmenu via a normal sequence other events still occur. I just gave it another try with a completely hooked design and it happens the same! Either the tray api is not absolute correct or MaxGui filters here something because it is not standard and expects something different. |
| ||
Hello! Sorry to bring up this zombie thread. Has anyone found a way to close an open popup menu for the tray icon if the user uses a mouse button > 1 or leaves the focus of the popup menu by pressing "on the desktop"? Steam and other tray apps detect that fine. I hope that BMX could detect such results as well (5 years later). I uploaded the exmaple source code + object file here: http://www.mediafire.com/download/1dq44bnba28b9cf/TrayIcon.zip |
| ||
Hi, what if you set focus on menu and try to detect lostfocus event ? -Henri |
| ||
From https://msdn.microsoft.com/en-us/library/windows/desktop/ms648002(v=vs.85).aspxLocal h:Int = Window.Query(QUERY_HWND) SetForegroundWindow(h) PopupWindowMenu Window, popmenu PostMessageW( h, WM_NULL, 0, 0) |
| ||
Thanks grable. This seems to fix one thing. Is there a way to check the EVENT_MOUSECLICK? Because now if the user clicks the right mouse button to close the popup menu. It's comming back up again right after that. MouseClick() doesn't work in the WaitEvent() structure. :( |
| ||
if the user clicks the right mouse button to close the popup menu. It's comming back up again right after that. Isnt that normal behaviour? All the other icons stuffed down there do the same... There is no EVENT_MOUSECLICK though, so youd have to make your own. But you can just as well use EVENT_MOUSEUP as it will be handled more correctly than EVENT_MOUSEDOWN (if its held down and then leave the icon, no event is fired) |