[Lazarus] TToolButton dropdown
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Apr 9 11:04:26 CEST 2012
On Mon, 9 Apr 2012 11:48:33 +0300
Juha Manninen <juha.manninen62 at gmail.com> wrote:
> 2012/4/9 Richard Mace <richard.mace at gmail.com>
>
> > 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
More information about the Lazarus
mailing list