CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Selecting field contents

by sbsllc » 11 Mar 2015 12:14

I am trying to implement a way so if I user clicks on a field the contents of that field is selected like the way it happens if they would tab to that field.

I have tried to call the select method for that field in the onfocus event:

procedure TfrmEdit.IWCGJQEdit2JQEventsFocus(Sender: TObject;
AParams: TStringList);
begin
IWCGJQEdit2.Select;
end;

This seems to work for the most part but only if I click on the right of the field contents. If I click on any of the text or if the text is right aligned and I click to the left of it the fields contents nothing not selected. Is there a better way to handle this?
sbsllc
 
Posts: 101
Joined: 01 Jul 2014 01:37

by Alexander Bulei » 11 Mar 2015 14:34

Hi sbsllc,

Checked here and works as expected..
What version of cg do you have?

If you only need select the text on focus event, i suggest you to use the OnFocus.Script, it will execute on client browser.

delphi code
procedure TIWForm3.IWAppFormCreate(Sender: TObject);
begin
IWCGJQEdit1.JQEvents.OnFocus.Script:= 'function(e){ ' + IWCGJQEdit1.GetIDJQuery + '.select(); }';
end;


Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by sbsllc » 12 Mar 2015 23:47

That script does not seem to work for me. When I try to implement that script and click on the field nothing is selected. I believe the script is being executed since following does work:

IWCGJQEdit2.JQEvents.OnFocus.Script:= 'function(e){ alert("alert");

I am not sure if it makes any difference or not but the edit field is in a TIWCGJQDialog that is not initially visible when the form is created.

I am running version 2.5.0.33
sbsllc
 
Posts: 101
Joined: 01 Jul 2014 01:37

by Alexander Bulei » 13 Mar 2015 10:43

Hi sbsllc,

It seems some problem in your side, with application.
Since, this script works as expected here in 3 tested browsers,
we can't help you with normal support.

P.S:

delphi code
IWCGJQEdit2.JQEvents.OnFocus.Script:= 'function(e){ alert("alert");


Incorrect. should be:

delphi code
IWCGJQEdit2.JQEvents.OnFocus.Script:= 'function(e){ alert("alert"); }';



Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by sbsllc » 13 Mar 2015 14:20

Hi Alexander,

Sorry, I left off that last piece of the script when I pasted the code in.
I will submit this issue to paid support since I can't seem to get it working.
sbsllc
 
Posts: 101
Joined: 01 Jul 2014 01:37


Return to JQEdit

cron

Who is online

Users browsing this forum: No registered users and 2 guests

Contact Us.