Jump to content

[Solved] Example of TUniEdit descendent with OnChange Overridden


Rebelss

Recommended Posts

Hello, i'm testing the UniGui trial and trying to create a new TMyUniEdit with the OnChange method overriden but can't figure out how :(

can someone post an example on how can i create a TUniEdit descendant with the OnChange method Overriden ?

Thanks!

Link to comment
Share on other sites

No one ?

we normally do something like this :

unit MyEdit;

interface

uses
  Vcl.StdCtrls, vcl.Dialogs;

Type
  TMyEdit = class(TEdit)
  public
    procedure Change; override;
  end;

procedure Register;

implementation

uses
  System.Classes;

procedure Register;
begin
  RegisterComponents('MySuite', [TMyEdit]);
end;


{ TMyEdit }

procedure TMyEdit.Change;
begin
  inherited;
  showmessage('MyOnChange');
end;

end.

But in Unigui the procedure "Change" doesn't exists on TUniEdit. 
 

Here is my code : 

unit MyUniEdit;

interface

uses
  Classes, uniGuiTypes, uniGUIClasses, uniGUIForm, UniEdit;

type
  TMyUniEdit = class(TUniEdit)
  public
    procedure Change; override;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MyUnigui', [TMyUniEdit]);
end;

{ TMyUniEdit }

procedure TMyUniEdit.Change;
begin
  inherited;
  if (Assigned(OnChange)) then
    showmessage('MyOnChange');
end;

end.

but the compiler message is : [dcc32 Error] MyUniEdit.pas(11): E2137 Method 'Change' not found in base class

Link to comment
Share on other sites

Hello guys, i figure out. I just have to override the DoOnChange event.

 

unit MyUniEdit;

interface

uses
  Classes, uniGuiTypes, uniGUIClasses, UniGuiDialogs, UniEdit;

type
  TMyUniEdit = class(TUniEdit)
  public
    procedure DoOnChange; override;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MyUnigui', [TMyUniEdit]);
end;

{ TMyUniEdit }

procedure TMyUniEdit.DoOnChange;
begin
  inherited DoOnChange;
  // code something
end;

end.

 

  • Upvote 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...