Within one of my MDL applications, I got a dialog with a ListBox with multiple row selection. When the user actives the mouse right button, a popup menu is shown and the user can select one of its items.
Before showing the popup, I save which rows are currently selected in the list and select only the row underneath the mouse pointer.
As soon as the dialog, that is opened by means of the selection of a popup menu item, is closed again, I restore the selection in the listbox to its original value.
So far so good.
A problem occurs when the user does not select an item within the popup menu but the popup is closed due to the user clicking somewhere outside of the popup menu. Also in that case I need to restore the original selection in the list.
I implemented hook functions that manage the events on the various dialog items.
When opening the popup I get the following events (in this order):
- PopopMenu DITEM_MESSAGE_BUTTON
- PulldownMenu DITEM_MESSAGE_DRAW
- PulldownMenuItem DITEM_MESSAGE_DRAW (for each menu item)
When a menu item is selected, I get these events:
- PopopMenu DITEM_MESSAGE_BUTTON
- PulldownMenu DITEM_MESSAGE_HIDE
- PulldownMenuItem DITEM_MESSAGE_BUTTON (this event opens the corresponding dialog)
- PulldownMenu DITEM_MESSAGE_BUTTON
- PopopMenu DITEM_MESSAGE_BUTTON
When the popup is closed without selecting a item, I only get:
- PopopMenu DITEM_MESSAGE_BUTTON
- PulldownMenu DITEM_MESSAGE_HIDE
The DITEM_MESSAGE_HIDE does not report additional info indicating why the menu was hidden. In fact, the corresponding arguments are as follows.
struct DialogItemHideArgs { int reserved; };
I tried to resolve it by starting a timeout at the DITEM_MESSAGE_HIDE. When the timeout expires I check if a second dialog was opened in the meantime. If not I restore the original selection within the list.
The problem is that it may take quite long between the events DITEM_MESSAGE_HIDE on the PulldownMenu and the DITEM_MESSAGE_BUTTON on the PulldownMenuItem. I've seen values near to a second. If I set the above mentioned timeout to 1 second it means that the user sees the selection within the list to be restored only a second after he/she closed the popup. I find this quite ugly.
Is there a way to determine the reason why a popup was closed (selection of menu item or user click outside of the popup)?
I user MicroStation ConnectEdition version 10.16.03.11 and corresponding SDK 10.16.00.084.
Thanks,
Robert