CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Copy to clipboard button

General discussion

by Alexander Bulei » 03 Oct 2016 16:38

Hi magosk,

We have alreayd implemented the public js function in 3.0.0.52.
Unfortunately, can't be called from IDE due the browser restrictions.
I will post small piece of code to how to use that asap.

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 magosk » 05 Oct 2016 15:19

OK, thanks! Please let me know when the exmple is ready (and a new Development build ready for download).

/Magnus
magosk
 
Posts: 181
Joined: 07 Oct 2013 08:41

by Alexander Bulei » 10 Oct 2016 17:46

Hi,

Demo in attachment.

P.S: setup 3.0.0.52+

Best Regards.
You do not have the required permissions to view the files attached to this post.
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 magosk » 11 Oct 2016 09:52

Hi Alexander and thank you very much for the new version and the demo! After testing, I have two important questions though:

1. The demo was for jQuery UI. Can the same JS code be used in jQuery Mobile (which is my target) without any problems?
2. The most difficult part for inexperienced mobile users is the text selection, and the current version of the demo does not help them with that. Maybe I was a bit unclear in my posts earlier, but I want the functionality of the button to be "copy the entire content of the edit into the clipboard" (so that the user does not have to bother with text selection at all). If the solution to this is "first (automatically) select all text in the edit, then copy the selection", that is fully acceptable (although you you would prefer if the mobile browsers built-in "copy popup" did not appear, as you have already copied the content). Is it easy to extend the JS code in JQButtonOptions.OnClick.Script to do this before calling CGCopyToClipBoard? Or would you have to modify your CGCopyToClipBoard function (e.g. with an optional "CopyAllText" bool parameter)?

Again, I'm sorry if these are obvious questions for most people, but I have not enough experience in HTML/JS frontend coding.

Best regards

Magnus Oskarsson
magosk
 
Posts: 181
Joined: 07 Oct 2013 08:41

by magosk » 12 Oct 2016 09:57

Hi again! I did some testing with a JQM application, did some googling and came up with the following JS code, which seems to work on both iOS and Android:

Code: Select all
  IWCGJQMButton1.JQMButtonOptions.Events.OnVClick.Script := Format(
    'function(e){' +
    '  document.getElementById("%s").setSelectionRange(0, 9999);' +
    '  CGCopyToClipBoard("%s");' +
    '}',
    [IWCGJQMEdit1.JQHTMLName, IWCGJQMEdit1.JQHTMLName]);


Note that the simpler select() did not work on iOS. Does this code seem OK to you, or do you have an alternative suggestion?

/Magnus
magosk
 
Posts: 181
Joined: 07 Oct 2013 08:41

by Alexander Bulei » 12 Oct 2016 11:17

Hi,

If this code work for you, good!

Just simple tip, replace 9999 by this code:

Code: Select all
document.getElementById("%s").value.length


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

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 4 guests

Contact Us.