Jump to content

How to make this code "ClientEvents.ExtEvents"


Luciano França

Recommended Posts

I need this code in runtime but it only works in designer

procedure TMainForm.UniButton3Click(Sender: TObject);
Var vScript: String;
begin

 vScript := 'function afterrender(sender, eOpts) { ';
 vScript := vScript + ' Ext.create(''Ext.tip.ToolTip'', {  ';
 vScript := vScript + '   target: sender.getEl(),  ';
 vScript := vScript + '   showDelay:1,  ';
 vScript := vScript + '   dismissDelay:99999,  ';
 vScript := vScript + '   maxHeight: 600,  ';
 vScript := vScript + '   maxWidth: 800,  ';
 vScript := vScript + '   minWidth: 500,  ';
 vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
 vScript := vScript + '  }); ';
 vScript := vScript + ' } ';

 UniButton3.ClientEvents.ExtEvents.Values['afterrender'] := vScript;

End;

 

Link to comment
Share on other sites

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  vScript: String;
begin
 vScript := 'afterrender=function afterrender(sender, eOpts) { '; // <----------
 vScript := vScript + ' Ext.create(''Ext.tip.ToolTip'', {  ';
 vScript := vScript + '   target: sender.getEl(),  ';
 vScript := vScript + '   showDelay:1,  ';
 vScript := vScript + '   dismissDelay:99999,  ';
 vScript := vScript + '   maxHeight: 600,  ';
 vScript := vScript + '   maxWidth: 800,  ';
 vScript := vScript + '   minWidth: 500,  ';
 vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
 vScript := vScript + '  }); ';
 vScript := vScript + ' } ';
 UniButton3.ClientEvents.ExtEvents.Add(vScript);                  // <----------
end;

 

Link to comment
Share on other sites

12 minutes ago, andyhill said:
procedure TMainForm.UniFormCreate(Sender: TObject);
var
  vScript: String;
begin
 vScript := 'afterrender=function afterrender(sender, eOpts) { '; // <----------
 vScript := vScript + ' Ext.create(''Ext.tip.ToolTip'', {  ';
 vScript := vScript + '   target: sender.getEl(),  ';
 vScript := vScript + '   showDelay:1,  ';
 vScript := vScript + '   dismissDelay:99999,  ';
 vScript := vScript + '   maxHeight: 600,  ';
 vScript := vScript + '   maxWidth: 800,  ';
 vScript := vScript + '   minWidth: 500,  ';
 vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
 vScript := vScript + '  }); ';
 vScript := vScript + ' } ';
 UniButton3.ClientEvents.ExtEvents.Add(vScript);                  // <----------
end;

 

 

Does not work

see attached demo.

 

 

Hint Unigui Dynamic.7z

Link to comment
Share on other sites

Actually it does

procedure TMainForm.UniButton1Click(Sender: TObject);
Var vScript: String;
begin
(* NOT IN BUTTON CLICK
 vScript := 'afterrender=function afterrender(sender, eOpts) { '; // <----------
 vScript := vScript + ' Ext.create(''Ext.tip.ToolTip'', {  ';
 vScript := vScript + '   target: sender.getEl(),  ';
 vScript := vScript + '   showDelay:1,  ';
 vScript := vScript + '   dismissDelay:99999,  ';
 vScript := vScript + '   maxHeight: 600,  ';
 vScript := vScript + '   maxWidth: 800,  ';
 vScript := vScript + '   minWidth: 500,  ';
 vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
 vScript := vScript + '  }); ';
 vScript := vScript + ' } ';
 UniButton1.ClientEvents.ExtEvents.Add(vScript);
*)
end;

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  vScript: String;
begin
 vScript := 'afterrender=function afterrender(sender, eOpts) { '; // <----------
 vScript := vScript + ' Ext.create(''Ext.tip.ToolTip'', {  ';
 vScript := vScript + '   target: sender.getEl(),  ';
 vScript := vScript + '   showDelay:1,  ';
 vScript := vScript + '   dismissDelay:99999,  ';
 vScript := vScript + '   maxHeight: 600,  ';
 vScript := vScript + '   maxWidth: 800,  ';
 vScript := vScript + '   minWidth: 500,  ';
 vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
 vScript := vScript + '  }); ';
 vScript := vScript + ' } ';
 UniButton1.ClientEvents.ExtEvents.Add(vScript);                  // <----------
end;

 

Link to comment
Share on other sites

5 minutes ago, andyhill said:

Actually it does

procedure TMainForm.UniButton1Click(Sender: TObject);
Var vScript: String;
begin
(* NOT IN BUTTON CLICK
 vScript := 'afterrender=function afterrender(sender, eOpts) { '; // <----------
 vScript := vScript + ' Ext.create(''Ext.tip.ToolTip'', {  ';
 vScript := vScript + '   target: sender.getEl(),  ';
 vScript := vScript + '   showDelay:1,  ';
 vScript := vScript + '   dismissDelay:99999,  ';
 vScript := vScript + '   maxHeight: 600,  ';
 vScript := vScript + '   maxWidth: 800,  ';
 vScript := vScript + '   minWidth: 500,  ';
 vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
 vScript := vScript + '  }); ';
 vScript := vScript + ' } ';
 UniButton1.ClientEvents.ExtEvents.Add(vScript);
*)
end;

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  vScript: String;
begin
 vScript := 'afterrender=function afterrender(sender, eOpts) { '; // <----------
 vScript := vScript + ' Ext.create(''Ext.tip.ToolTip'', {  ';
 vScript := vScript + '   target: sender.getEl(),  ';
 vScript := vScript + '   showDelay:1,  ';
 vScript := vScript + '   dismissDelay:99999,  ';
 vScript := vScript + '   maxHeight: 600,  ';
 vScript := vScript + '   maxWidth: 800,  ';
 vScript := vScript + '   minWidth: 500,  ';
 vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
 vScript := vScript + '  }); ';
 vScript := vScript + ' } ';
 UniButton1.ClientEvents.ExtEvents.Add(vScript);                  // <----------
end;

 

 

I can't use it in the form's onCreate event

I need it to be in a button event because several Hints situations I will change the hint after the form has already been created

 

 

Link to comment
Share on other sites

6 hours ago, Luciano França said:

I can't use it in the form's onCreate event

I need it to be in a button event because several Hints situations I will change the hint after the form has already been created

You should use the OnCreate event.

Use this approach:

1. OnCreate event ->

procedure TMainForm.UniFormCreate(Sender: TObject);
Var 
  vScript: String;
begin
  vScript := 'afterrender=function afterrender(sender, eOpts) { '; // 
  vScript := vScript + ' sender._tip = Ext.create(''Ext.tip.ToolTip'', {  '; //<----------
  vScript := vScript + '   target: sender.getEl(),  ';
  vScript := vScript + '   showDelay:1,  ';
  vScript := vScript + '   dismissDelay:99999,  ';
  vScript := vScript + '   maxHeight: 600,  ';
  vScript := vScript + '   maxWidth: 800,  ';
  vScript := vScript + '   minWidth: 500,  ';
  vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
  vScript := vScript + '  }); ';
  vScript := vScript + ' } ';

  UniButton1.ClientEvents.ExtEvents.Add(vScript);

end;

2. After... ->

UniButton1.JSInterface.JSCall('_tip.setHtml', ['<a style=''font-size:14px;''>New Hint</a>']);

 

Link to comment
Share on other sites

On 4/15/2023 at 12:31 AM, Sherzod said:

You should use the OnCreate event.

Use this approach:

1. OnCreate event ->

procedure TMainForm.UniFormCreate(Sender: TObject);
Var 
  vScript: String;
begin
  vScript := 'afterrender=function afterrender(sender, eOpts) { '; // 
  vScript := vScript + ' sender._tip = Ext.create(''Ext.tip.ToolTip'', {  '; //<----------
  vScript := vScript + '   target: sender.getEl(),  ';
  vScript := vScript + '   showDelay:1,  ';
  vScript := vScript + '   dismissDelay:99999,  ';
  vScript := vScript + '   maxHeight: 600,  ';
  vScript := vScript + '   maxWidth: 800,  ';
  vScript := vScript + '   minWidth: 500,  ';
  vScript := vScript +  '   html: "<a style=''font-size:14px;''>Test com Hint</a>"  ';
  vScript := vScript + '  }); ';
  vScript := vScript + ' } ';

  UniButton1.ClientEvents.ExtEvents.Add(vScript);

end;

2. After... ->

UniButton1.JSInterface.JSCall('_tip.setHtml', ['<a style=''font-size:14px;''>New Hint</a>']);

 

 

It works very grateful.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...