I used to have a context menu attached to a wxTaskBarIcon, working as one would expect a context menu to work. Now I wanted to call a context menu on demand. My App does not always show an active GUI, btw.
If I use
Code: Select all
PopupMenu(m_taskBarMenu);
If I use it in a class which creates a visible GUI (frames etc.) and show that GUI, I can create that context menu, but it won't disappear when clicking somewhere else (focus lost) or hitting esc.
I then used wxPopupTransientWindow. It does react to ESC and closes on focus change automatically.
If I create an instance of this class and call the PopupMenu afterwards, it would work. But kinda weird.
Closes on click and esc alright. Menu Events go the class, which calls the code, but the popup needs a parent window and it just takes the window created before? Thats confusing.
Code: Select all
wxPopupTransientWindow *ptw = new wxPopupTransientWindow(this);
ptw->Show();
PopupMenu(m_taskBarMenu);
//ptw->PopupMenu(m_taskBarMenu); // Or like this, doesn't matter
Cheers Natu