Luciano França Posted April 14, 2023 Share Posted April 14, 2023 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; Quote Link to comment Share on other sites More sharing options...
andyhill Posted April 14, 2023 Share Posted April 14, 2023 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; Quote Link to comment Share on other sites More sharing options...
Luciano França Posted April 14, 2023 Author Share Posted April 14, 2023 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 Quote Link to comment Share on other sites More sharing options...
andyhill Posted April 14, 2023 Share Posted April 14, 2023 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; Quote Link to comment Share on other sites More sharing options...
Luciano França Posted April 14, 2023 Author Share Posted April 14, 2023 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2023 Share Posted April 15, 2023 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>']); Quote Link to comment Share on other sites More sharing options...
Luciano França Posted April 16, 2023 Author Share Posted April 16, 2023 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.