Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TToolbutton Dropdown menu

51 views
Skip to first unread message

Paul

unread,
Apr 23, 2008, 5:47:24 AM4/23/08
to
Hi -

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

Markus.Humm

unread,
Apr 23, 2008, 1:35:44 PM4/23/08
to
Hello,

maybe KeyPreview of the form and a OnKeypress handler on the form which
would manually call the click event of the button?

Greetings

Markus

Xu, Qian

unread,
Apr 24, 2008, 7:22:05 PM4/24/08
to
A good example is the menu bar of Internet Explorer. When you press
ALT+F, the "File" menu will popup. I did the same with TToolbar and
Dropdown-Menu as well.

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/

0 new messages