IceCold
IceCold

Reputation: 21134

How do I know when the user clicked the TButtonedEdit.OnRightButton?

I am building (in Delphi XE7) a custom control based on TGroupBox. It contains among other controls a TButtonedEdit.

constructor TMyControl.Create(aOwner: TComponent);
VAR myIcon: TIcon;
begin
 inherited Create(aOwner);
 ...
 edtPath:= TButtonedEdit.Create(Self);
 WITH edtPath DO
  begin
   Parent                := Self;
   RightButton.Glyph.OnClick:= MyOwnHandler;      <- Here error: "Cannot access protected symbol TEditButton.Glyph"
   RightButton.OnRightButtonClick:= MyOwnHandler; <- Here error: "Undeclared identifier: 'OnRightButtonClick'"
  end;
end;

How do I know when the user pressed the RightButton?

GetOnRightButtonClick and SetOnRightButtonClick are private. The same for RightButton.Glyph.OnClick.

Upvotes: 0

Views: 134

Answers (1)

Jerry Dodge
Jerry Dodge

Reputation: 27276

There's no reason to access RightButton or anything beyond the control itself. Just assign your event handler directly to TButtonedEdit.OnRightButtonClick. Any events you find within the control's properties are only intended to be used internally by the control itself. These events are not published, and therefore you shouldn't try to use them.

WITH edtPath DO
begin
  Parent                := Self;
  OnRightButtonClick:= MyOwnHandler;
end;

Upvotes: 2

Related Questions