Continue of this topic:
Drop down menu for TButton
I have wrote a generic code for DropDown memu with any TControl, but for som
If I understand you correctly, then the requirements are:
Realize that, disregarding the implementation of requirement 1 for the moment, requirement 2 happens automatically: when you click outside a PopupMenu, the PopupMenu will close. This concludes to that the implementation of the first should not interfere with the second.
Possible solutions:
TPopupMenu.Popup will not return until the PopupMenu is closed.OnClick event of a Control:
OnMouseDown event of the control is assigned to a custom handler,OnClick event),OnMouseDown event handler is called,Note: a possibly already OnMouseDown event setting is not saved and gone!
A TCustomButton handles click events by responding to a by Windows send CN_COMMAND message. That is a specific Windows BUTTON sytem class control characteristic. By canceling the mouse capture mode, this message is not send. Thus the Control's OnClick event is not fired on the second click.
A TPanel handles click events by adding the csClickEvents style to its ControlStyle property. This is a specific VCL characteristic. By aborting execution, subsequent code due to the WM_LBUTTONDOWN message is stopped. However, the OnClick event of a TPanel is fired somewhere down its WM_LBUTTONUP message handler, thus the OnClick event is still fired.
Use davea's answer on your other question wherein he simply does nothing if the saved time of the PopupMenu's closing was within the last 100 milliseconds.