Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Would like to add code to OnChange



Permlink Replies: 4 - Last Post: Dec 6, 2017 9:29 AM Last Post By: Lajos Juhasz Threads: [ Previous | Next ]
Robert Yost

Posts: 12
Registered: 5/2/08
Would like to add code to OnChange
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 6, 2017 8:41 AM
***edit*** I also would like to know how to override (I think this means add code to) the OnFocus (Maybe means OnEnter)

I have a component based on TUnimEdit

 TmUniRyEdit = class(TUnimEdit)


I would like to add some code to the OnChange Event

I tried

public
    procedure OnChange; override;
 
...
 
procedure TmUniRyEdit.OnChange;
begin
  inherited;
 
end;


Similar to how Remy LeBeau showed me how to do it with 'Loaded'

But I get:
[dcc32 Error] mUniRyEdit.pas(32): E2137 Method 'OnChange' not found in base class

however, if I look at TUnimEdit:
  TUnimEdit = class(TUnimCustomEdit)
  published
    property Align;
    property Anchors;
    property ClientEvents;
    property Text;
    property CharCase;
    property PasswordChar;
    property EmptyText;
    property FieldLabel;
    property FieldLabelAlign;
    property FieldLabelWidth;
    property Enabled;
    property Flex;
    property ReadOnly;
    property ScreenMask;
    property LayoutConfig;
 
    property OnKeyUp;
    property OnEnter;
    property OnExit;
    property OnChange;  <<<<<<
    property OnChangeValue;
    property OnAjaxEvent;
  end;

Can you tell me what I am doing wrong?

Edited by: Robert Yost on Dec 6, 2017 9:04 AM
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Would like to add code to OnChange
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 6, 2017 9:04 AM   in response to: Robert Yost in response to: Robert Yost
Robert Yost wrote:

I have a component based on TUnimEdit

 TmUniRyEdit = class(TUnimEdit)


I would like to add some code to the OnChange Event

I tried

public
    procedure OnChange; override;
 
...
 
procedure TmUniRyEdit.OnChange;
begin
  inherited;
 
end;


Similar to how Remy LeBeau showed me how to do it with 'Loaded'

But I get:
[dcc32 Error] mUniRyEdit.pas(32): E2137 Method 'OnChange' not found
in base class
[snip]
property OnChange; <<<<<<
property OnChangeValue;
property OnAjaxEvent;
end;
{code}
Can you tell me what I am doing wrong?

You are trying to override a property and you cannot do that, you can
only override virtual methods.

Robert Yost

Posts: 12
Registered: 5/2/08
Re: Would like to add code to OnChange
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 6, 2017 9:09 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
You are trying to override a property and you cannot do that, you can
only override virtual methods.

Thanks, I see that now.

So how can I have some code executed when the control gets focus or is changed?
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Would like to add code to OnChange
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 6, 2017 9:10 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
According to
http://www.unigui.com/doc/online_help/api/!!NAVID_!!MEMBEROVERVIEW_unimEdit_TUnimCustomEdit_ST(14)_SEC_Protected_Methods.html

there is a virtual DoOnChange method, you should try to override this
one.

Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Would like to add code to OnChange [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 6, 2017 9:29 AM   in response to: Robert Yost in response to: Robert Yost
Robert Yost wrote:


edit I also would like to know how to override (I think this means
add code to) the OnFocus (Maybe means OnEnter)

You should usually try to find the method that calls the event, its
name usually starts with do, I can see there's a DoEnter method
(http://www.unigui.com/doc/online_help/api/uniGUIClasses_TUniFormControl_DoEnter.html).

I don't have UNIGUI, but in case of the VCL the method is:

procedure TWinControl.DoEnter;
begin
if Assigned(FOnEnter) then FOnEnter(Self);
end;

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02