Copy to Clipboard

Forum to discuss the new web client version of Servoy.

Copy to Clipboard

Postby rph » Fri Dec 11, 2020 12:54 pm

Hi

What we need is a possibility that a user can click on a button and then has some information in the clipboard so he can paste it in other solutions (like for example in an e-mail or word-document). In the Servoy-Smart-Client this works with "application.setClipboardContent(string)", but this doesn't work in NG-Client.

How can we handle this in NG-Client? Are there any components or services that can handle this? There are JavaScript-Libraries out there that can do this (like for example "https://clipboardjs.com"), but I was wondering, if Servoy has some stuff like this already built in?

Best
Roland
rph
 
Posts: 94
Joined: Wed Aug 10, 2011 11:44 am
Location: Cham, Switzerland

Re: Copy to Clipboard

Postby mboegem » Fri Dec 11, 2020 6:41 pm

Hi Roland,

currently that's only available when you run NG client of the NGDesktop client.

However, a while ago I've put together a small service which should do the job.
Haven't had time to properly finish/test it, but if you feel like it: give it a spin
solClipboard.zip


Hope this helps
You do not have the required permissions to view the files attached to this post.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Copy to Clipboard

Postby rph » Mon Dec 14, 2020 12:01 pm

Thank you very much, Marc. I'll try your service and give feedback!

Best
Roland
rph
 
Posts: 94
Joined: Wed Aug 10, 2011 11:44 am
Location: Cham, Switzerland

Re: Copy to Clipboard

Postby rph » Mon Dec 14, 2020 12:23 pm

Works exactly as I need it! Tested in Chrome (87.0.4280.88), Firefox (83.0) and MS Edge (87.0.664.60).

Thanks again, Marc

Best
Roland
rph
 
Posts: 94
Joined: Wed Aug 10, 2011 11:44 am
Location: Cham, Switzerland

Re: Copy to Clipboard

Postby rafig » Fri Aug 18, 2023 4:57 pm

mboegem wrote:Hi Roland,
currently that's only available when you run NG client of the NGDesktop client.
However, a while ago I've put together a small service which should do the job.
Haven't had time to properly finish/test it, but if you feel like it: give it a spin
solClipboard.zip

Hope this helps

Hi Marc,
I just tried your 'service' in the latest version of Servoy [2023.6.0.3883], but unfortunately it does not work in either TiNG or NG client.
I would really appreciate it if you might be able to have a look at what you created and see if you can tweak it to work with this (& future) versions, as I am currently migrating a new client from a very old FileMaker Pro solution and part of that old solution had scripts that copied things like names & address to the clipboard to allow easy pasting in to Word (or whatever) documents and the Servoy "application.setClipboardContent('text')" command doesn't work in either also (even though Wiki states it does in NG client).
I've put in the obvious workaround of a 'dialog' with the specific text in a text area for manual copy/paste, but it's not ideal ;-)
Thanks
Rafi
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Copy to Clipboard

Postby mboegem » Mon Aug 21, 2023 10:50 am

Hi Rafi,

As you mentioned Servoy does have its own 'copy to clipboard' function.
I've tried that and it works for me in 2023.6 (TiNG), but also in NG for older versions.
However, there's a 'gotcha' here, the command will only work if being called from a button on a form, so the form must be focussed.
If you open the browser inspector and look in the console, you can see errors appearing if you call the command from the command console.

As for your request on my NG-service:
I don't believe I will be continuing work on that.
Like I wrote back in 2020:
Haven't had time to properly finish/test it, but if you feel like it: give it a spin

At that time I don't believe application.setClipboardContent did work in NG and now it does it feels like putting effort in something that doesn't add more value.
Hope you can understand that.

Nevertheless, I think my NG-service should still work for NG (not TiNG):
It has been a while, but I believe my clipboard-service as well as the native application.setClipboardContent command do a similar thing depending on the browser and version.
When I grabbed some code and wrapped this into the service, I bumped into a 'not working' service myself when calling the command from command line: the command needs to be executed from a button on the form.

Hope this helps and if you have any particular use cases which are not currently supported, I think you should raise a support request at support.servoy.com
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Copy to Clipboard

Postby rafig » Mon Aug 21, 2023 9:24 pm

Hi Marc,
thanks for your reply.
After reading it, I checked console errors & then 'googled' message and now realise that the issue is SAFARI!
There seems to be a 'bug' that stops the clipboard command from working (mainly reported by developers trying to auto-play videos).
It works fine in Chrome & Firefox, but both myself & the client use (macOS) Safari as default browser, so using another browser for Servoy is not ideal...
I will probably have to raise a support case for this now (& carry on with current 'fix' of manual copy/paste from a dialog)
Thanks
Rafi
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Copy to Clipboard

Postby robert.edelmann » Tue Aug 22, 2023 8:14 pm

Just for clarification, application.setClipboardContent() works on NG Client Web (with the exception of Safari), and in NG Desktop I have to use plugins.ngdesktoputils.setClipboardContent() to set the clipboard, right?

So it's something like

Code: Select all
if (scopes.svySystem.isNGClient() && plugins['ngdesktoputils'] && plugins['ngdesktoputils'].isNGDesktop()) {
   plugins.ngdesktoputils.setClipboardContent(...);
} else {
   application.setClipboardContent(...);
}

to get everyone but safari-users happy?
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 120
Joined: Wed Aug 14, 2013 6:12 pm

Re: Copy to Clipboard

Postby rafig » Wed Aug 23, 2023 12:33 pm

robert.edelmann wrote:Just for clarification, application.setClipboardContent() works on NG Client Web (with the exception of Safari), and in NG Desktop I have to use plugins.ngdesktoputils.setClipboardContent() to set the clipboard, right?
to get everyone but safari-users happy?

Hi
I can only comment on Ti/NG web client, but "application.setClipboardContent()" does work on Mac browsers other than Safari...
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Copy to Clipboard

Postby rafig » Tue Aug 29, 2023 7:39 pm

Asking here first, but if I don't get an answer will make a new post...
Is there a way to find the 'browser agent' when using Ti/NG client, so that I can make my clipboard code use the working function when not in Safari, otherwise use the work-around?
Thanks
Rafi
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Copy to Clipboard

Postby sean » Tue Aug 29, 2023 9:03 pm

Hi Rafi,

This should get it:

Code: Select all
plugins.ngclientutils.getUserAgent()


Best,
Sean
Software Engineer
Servoy USA
sean
 
Posts: 383
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: Copy to Clipboard

Postby rafig » Tue Aug 29, 2023 10:53 pm

sean wrote:Hi Rafi,
This should get it:
Code: Select all
plugins.ngclientutils.getUserAgent()

Best,
Sean

Thanks Sean!
It would be great if Servoy could fix this 'issue' though ;-)
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Copy to Clipboard

Postby rafig » Wed Aug 30, 2023 7:30 pm

In case it saves someone 1 minute of coding, (I have a global boolean variable 'isSafari')
Code: Select all
      var browser_name = plugins.ngclientutils.getUserAgent() ;
      isSafari = (utils.stringPosition(browser_name, 'Safari', 1, 1) >= 1);
      application.output ( 'isSafari ' + isSafari + ' [' + browser_name + ']' );

:D
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Copy to Clipboard

Postby rafig » Fri Sep 29, 2023 2:11 pm

After chatting with Johan at ServoyCamp, Servoy is making this call at the lowest level
Code: Select all
navigator.clipboard.writeText(content) ;

Using that, I found some articles that basically say that to get it to work in Safari you need to use
Code: Select all
navigator.clipboard.write(content) ;

Please see these links for more details & I hope that Servoy can update the low level code to fix, assuming this also works for all other browsers ;-)
https://stackoverflow.com/questions/66312944/javascript-clipboard-api-write-does-not-work-in-safari
https://developer.apple.com/forums/thread/691873
Thanks
Rafi
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Copy to Clipboard

Postby rafig » Mon Mar 11, 2024 4:12 pm

As this has still been fixed (as of latest release version [not tested RC], I have created a case for it
https://support.servoy.com/browse/SVY-19036
I hope it can be pushed in to 2024.3
Thanks

Rafi
Servoy Certified Developer
Image
rafig
 
Posts: 724
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 9 guests

cron