I was wanting to use a button that would show a pop-up menu when
activated. At first I tried using actions and the Action toobar. I
found this to be problematic.
I then tried a TToolbuton and TToolbar. This seemed fine if the user
used the mouse to click on the button. The menu would be shown as
expeced. However, I want the user to be able to activate the button
using the shortcut key assigned.
So in essence - whenthe cutton is clicked the dropdown menu is
shown.. When accessed via the shortcut key (which you would expect to
be behave the same a clicking on the button) nothing happens.
The only way I can seem to get it to respond to a shortcut key is to
have the following code assigned to the Onclick procedure..
==========================================
var
P: TPoint;
R: TRect;
h,w : integer;
begin
R := SendToBut.ClientRect;
P := SendToBut.ClientToScreen(Point(R.Left, R.Bottom)); // Convert
into point coordinates
TransMenu.Popup(P.X, P.y);
==========================================
Seems a bit silly yo have to go to these lenghts to show a a dropdown
menu on something that is designed to show one ?
Anyway, any thoughts - alternative approaches would be much
appreciated.
Many thanks..
Paul.
OS : Windows XP Service Pack 2
Delphi : 2005 Service Pack 3 Installed
Version 9.0.1935.22056
CPU : AMD 3500+
Memory 1Gig
maybe KeyPreview of the form and a OnKeypress handler on the form which
would manually call the click event of the button?
Greetings
Markus
If your button has a caption "Text", you can change it to "&Text". And
now on by pressing ALT+T, its associated menu can popup. I hope this helps.
--
Best regards
Xu, Qian (stanleyxu)
http://stanleyxu2005.blogspot.com/