TPopupMenu.OnClose is called incorrectly
Original Reporter info from Mantis: cobines
-
Reporter name:
Original Reporter info from Mantis: cobines
- Reporter name:
Description:
In addition to calling OnClose when closing popup menu this event is also called when showing another popup menu. This is because the ActivePopupMenu global variable is not cleared when the popup menu is closed. The following code in TPopupMenu.Popup:
if ActivePopupMenu <> nil then ActivePopupMenu.Close;
calls TPopupMenu.Close of the previously shown menu (not visible already) which in turn calls another OnClose event for that previous menu.
I attached a test application. Try the following:
- Run application.
- Right click inside the group box, select menu item.
- Right click inside the group box, press Escape.
The log on QT/Linux is:
PopupMenu: OnPopup
PopupMenu: OnClose
MenuItem: OnClick
PopupMenu: OnClose
PopupMenu: OnPopup
PopupMenu: OnClose
OnClose is called three times. Also, the order of events is wrong when clicking on menu item:
OnPopup -> OnClose -> OnClick
But I think it should be:
OnPopup -> OnClick -> OnClose
On GTK2/Linux the log shows the following, which is also expected behaviour:
PopupMenu: OnPopup
MenuItem: OnClick
PopupMenu: OnClose
PopupMenu: OnPopup
PopupMenu: OnClose
I haven't tested on QT/Windows. I'm using libQT 4.5.3. Lazarus rev. 23378.
Mantis conversion info:
- Mantis ID: 15465
- Version: 0.9.29 (SVN)
- Fixed in revision: 23397 (#250ca33f)
- Target version: 0.9.30