Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5932289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:48:49+00:00 2026-05-22T14:48:49+00:00

I have my custom class witch is derived from TButton: TLoginResultEvent = procedure (Sender:

  • 0

I have my custom class witch is derived from TButton:

TLoginResultEvent = procedure (Sender: TObject; LoginResult: boolean) of object;
TLoginButton = class(TButton)
    private
      fLogin: TLoginChooser;
      fOnClick: TLoginResultEvent;
    public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;

      procedure OnClickResult(Sender: TObject; LoginResult: boolean);
    published
      property Login: TLoginChooser read fLogin write fLogin;
      property OnClick: TLoginResultEvent read fOnClick write fOnClick;
  end;

in constructor I added:

constructor TLoginButton.Create(AOwner: TComponent);
begin
  inherited;

  fOnClick := OnClick;
  OnClick := OnClickResult;
end;

But when I click on the button it’s not firing OnClickResult, what am I doing wrong? Is it possible to “override” OnClick event handler or should I hide it and make for example OnResultClick event?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:48:50+00:00Added an answer on May 22, 2026 at 2:48 pm

    When writing components, you should not use the event handlers to implement custom behaviour. Instead you should override the code calling these event handlers. In this case, forget about setting OnClick. Instead, simply add

    public
      procedure Click; override;
    

    to your class declaration, and implement

    procedure TLoginButton.Click;
    begin
      inherited; // call the inherited Click method.
      // Do something new.
    end;
    

    The event handlers are there to be used by the developer using the component. The component writer should not use them herself.

    If you want the component user to see a different ‘OnClick’ method, you have to implement this yourself, like

    type
      TLoginResultEvent = procedure(Sender: TObject; LoginResult: boolean) of object;
    
    ...
    
    TLoginButton = class(TButton)
    private
      FOnClick: TLoginResultEvent;
    ...
    public
      procedure Click; override;
    ...
    published
      property OnClick: TLoginResultEvent read FOnClick write FOnClick;
    ...
    
    procedure TLoginButton.Click;
    begin
      inherited;
      if Assigned(FOnClick) then
        FOnClick(Self, true); // or false...
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class derived from JTree with custom TreeCellRenderers. I have implemented drag
I have a custom class loader which extends from a URLClassLoader. I added a
I have implemented a custom trace listener (derived from TextWriteTraceListener ) and now I
I want to build a jar containing a class which I have derived from
I have an application where I have one custom view which is derived from
I have my own custom control derived from System.Windows.Forms.TreeView which is present on the
I have a class with a custom each-method: class CurseArray < Array def each_safe
I have a class with a custom indexer like so public string this[VehicleProperty property]
I have a class which is marked with a custom attribute, like this: public
I have a custom class loader so that a desktop application can dynamically start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.