Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-04

TToolButton dropdown

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Mace

Hi,
I have a TToolButton in a tool bar, with it's style set to tbsDropDown and have linked the DropDownMenu property to a drop down menu. All is working fine when I click on the "down arrow" to the right of the button, however, I'd really like the button to also activate the dropdown menu when it is clicked.
Could someone give me an example of how I could code that please for the OnClick event of the button?

Thanks

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120409/4fe9ee99/attachment.html>

Reply by email

Juha Manninen
to Richard Mace

2012/4/9 Richard Mace

Show quoted text 9 lines
Hi, I have a TToolButton in a tool bar, with it's style set to tbsDropDown and have linked the DropDownMenu property to a drop down menu. All is working fine when I click on the "down arrow" to the right of the button, however, I'd really like the button to also activate the dropdown menu when it is clicked. Could someone give me an example of how I could code that please for the OnClick event of the button?

Don's set the style to tbsDropDown.
As an example, you can look at Lazarus sources. MoreBitBtn is set in packager/PackageEditor.pas.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120409/6f07fead/attachment.html>

Reply by email

Mattias Gaertner
to Juha Manninen
Show quoted text 10 lines
2012/4/9 Richard Mace > Hi, > I have a TToolButton in a tool bar, with it's style set to tbsDropDown and > have linked the DropDownMenu property to a drop down menu. > All is working fine when I click on the "down arrow" to the right of the > button, however, I'd really like the button to also activate the dropdown > menu when it is clicked. > Could someone give me an example of how I could code that please for the > OnClick event of the button?
procedure TForm1.ToolButton1Click(Sender: TObject);
var
  APoint: TPoint;
begin
  APoint := ToolButton1.ClientToScreen(Point(0, ToolButton1.ClientHeight));
  if ToolBar1.IsRightToLeft then Inc(APoint.X, ToolButton1.Width);
  ToolButton1.DropdownMenu.PopUp(APoint.X,APoint.Y);
end;
Don's set the style to tbsDropDown. As an example, you can look at Lazarus sources. MoreBitBtn is set in packager/PackageEditor.pas.

Mattias

Reply by email