mierlp Posted December 15, 2016 Share Posted December 15, 2016 Hi, Is in not possible to copy text to the clipboard using:dbmemo.SelectAlldbmemo.CopyToClipboard Regards Peter Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted December 16, 2016 Share Posted December 16, 2016 CopytoClipboard will not work in browser like vcl application. Using this function directly copy text to clipboard of server, not client document.execCommand('copy') must be triggered by the user. It's not only from the console, it's anywhere that's not inside an event triggered by the user.Due to this reason btnCopyToClipboard.ClientEvents.ExtEvents.Values['click'] must be defined in UniFormCreate. Solution : btnCopyToClipboard.ClientEvents.ExtEvents.Values['click']:='function click(sender, e, eOpts) '+ ' { '+ ' var textarea = document.getElementById("'+memSummary.JSName+'_id-inputEl"); '+ ' textarea.select(); '+ ' try { '+ ' var successful = document.execCommand(''copy''); '+ ' if(successful) console.log(''Copied!''); '+ ' else console.log(''Unable to copy!''); '+ ' } catch (err) { '+ ' console.log(''Unsupported Browser!''); '+ ' } '+ ' }'; Select All : UniSession.AddJS(' var textarea = document.getElementById("'+memSummary.JSName+'_id-inputEl"); '+ ' textarea.select(); '); 1 Quote Link to comment Share on other sites More sharing options...
mierlp Posted December 16, 2016 Author Share Posted December 16, 2016 Thanks for the explanation Hayri. I'm going to try to implement you're code. 1 Quote Link to comment Share on other sites More sharing options...
picyka Posted February 3, 2018 Share Posted February 3, 2018 Does the above code work? I needed something like that. Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted February 3, 2018 Share Posted February 3, 2018 Hi picyka, I am using this code in my projects. You can use it. Quote Link to comment Share on other sites More sharing options...
picyka Posted February 3, 2018 Share Posted February 3, 2018 Mobile ? Quote Link to comment Share on other sites More sharing options...
picyka Posted February 3, 2018 Share Posted February 3, 2018 btnCopy.ClientEvents.ExtEvents.Values['click']:='function tap(sender, e, eOpts) '+ ' { '+ 'var copyText = document.getElementById("'+UnimMemoCopy.JSName+'_id-inputEl");' + ' copyText.select(); ' + 'document.execCommand("Copy");' + ' }'; Quote Link to comment Share on other sites More sharing options...
adan200 Posted November 12, 2018 Share Posted November 12, 2018 Can use this code with Label? BR Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 12, 2018 Share Posted November 12, 2018 4 hours ago, adan200 said: Can use this code with Label? BR Hello, Sorry, what do you mean?! Quote Link to comment Share on other sites More sharing options...
azago Posted May 27, 2019 Share Posted May 27, 2019 i've used btnCopyToClipboard.ClientEvents.ExtEvents.Values['click']:='function click(sender, e, eOpts) '+ ' { '+ ' var textarea = document.getElementById("'+memSummary.JSName+'_id-inputEl"); '+ ' textarea.select(); '+ ' try { '+ ' var successful = document.execCommand(''copy''); '+ ' if(successful) console.log(''Copied!''); '+ ' else console.log(''Unable to copy!''); '+ ' } catch (err) { '+ ' console.log(''Unsupported Browser!''); '+ ' } '+ ' }'; for copy data to Clipboard and work fine. i tried to write the syntax to Paste data from clipboard bPaste.ClientEvents.ExtEvents.Values['click']:='function click(sender, e, eOpts) '+ ' { '+ ' var textarea = document.getElementById("'+ memSummary.JSName+'_id-inputEl"); '+ ' textarea.focus(); '+ ' try { '+ ' var successful = document.execCommand(''paste''); '+ ' if(successful) console.log(''Pasted!''); '+ ' else console.log(''Unable to paste!''); '+ ' } catch (err) { '+ ' console.log(''Unsupported Browser!''); '+ ' } '+ ' }'; *) but not work. I don't know java. I tried to build the syntax for assonance ... Any idea how to write the correct code ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 27, 2019 Share Posted May 27, 2019 13 minutes ago, azago said: I don't know java. I tried to build the syntax for assonance ... Any idea how to write the correct code ? Hi, Sorry, I did not quite understand you, the first code is correct, and what is the second code?! Quote Link to comment Share on other sites More sharing options...
azago Posted May 28, 2019 Share Posted May 28, 2019 I need to insert a button in the procedure. Pressing it copies the clipborad into a memo or edit field. I tried to build it starting from the inverse (field copy to clipboard) but I couldn't (see written routine). I wanted to know how to do it through JS. Quote Link to comment Share on other sites More sharing options...
azago Posted June 1, 2019 Share Posted June 1, 2019 I send un example for my request. I need to copy the clipboard into a uniedit field Thanks _Request_Paste.7z Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted June 4, 2019 Share Posted June 4, 2019 Hello @azago Please find attached file. _Request_Paste.rar Quote Link to comment Share on other sites More sharing options...
Frederick Posted April 21, 2022 Share Posted April 21, 2022 On 12/16/2016 at 2:01 PM, Hayri ASLAN said: btnCopyToClipboard.ClientEvents.ExtEvents.Values['click']:='function click(sender, e, eOpts) '+ ' { '+ ' var textarea = document.getElementById("'+memSummary.JSName+'_id-inputEl"); '+ ' textarea.select(); '+ ' try { '+ ' var successful = document.execCommand(''copy''); '+ ' if(successful) console.log(''Copied!''); '+ ' else console.log(''Unable to copy!''); '+ ' } catch (err) { '+ ' console.log(''Unsupported Browser!''); '+ ' } '+ ' }'; I use the above code to copy a TUniEdit text property to the clipboard. How do I notify the user by way of a dialogue box upon completion instead of logging it to the console? -- Frederick (UniGUI Complete - Professional Edition 1.90.0.1560) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 21, 2022 Share Posted April 21, 2022 Hello, you can use js alert method or send a request to server using ajaxRequest method. Quote Link to comment Share on other sites More sharing options...
Frederick Posted April 21, 2022 Share Posted April 21, 2022 1 hour ago, Sherzod said: Hello, you can use js alert method or send a request to server using ajaxRequest method. Thanks. I replaced "console.log()" with "alert()" and the dialogue box is shown but it is ugly. Is it possible to change it so that it displays like a ShowMessage() or using SweetAlert()? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 21, 2022 Share Posted April 21, 2022 4 minutes ago, Frederick said: Is it possible to change it so that it displays like a ShowMessage() or using SweetAlert()? 1 hour ago, Sherzod said: or send a request to server using ajaxRequest method. Quote Link to comment Share on other sites More sharing options...
Frederick Posted April 21, 2022 Share Posted April 21, 2022 In the form's OnCreate event, I have the following code:- spdCopy.ClientEvents.ExtEvents.Values['click']:='function click(sender, e, eOpts) '+ ' { '+ ' var textarea = document.getElementById("'+edtPaylink.JSName+'_id-inputEl"); '+ ' textarea.select(); '+ ' try { '+ ' var successful = document.execCommand(''copy''); '+ ' if(successful) var text=''Copied!''; '+ ' else var text = ''Unable to copy!''; '+ ' } catch (err) { '+ ' var text = ''Unsupported Browser!''; '+ ' } '+ ' }'; In the TUniSpeedButton's ClientEvents.ExtEvents's click event, I have the following code:- function click(sender, e, eOpts) { ajaxRequest(sender, 'customEvent', { name: sender.text, width: sender.getWidth() } ); } In the OnAjaxEvent of the button, I have the following:- if SameText(EventName, 'customEvent') then begin ShowMessage(Params['name'].AsString + ' ' + Params['width'].AsString); end; There is no message shown after the button is clicked. What am I missing here? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 21, 2022 Share Posted April 21, 2022 5 minutes ago, Frederick said: In the TUniSpeedButton's ClientEvents.ExtEvents's click event, I have the following code:- function click(sender, e, eOpts) { ajaxRequest(sender, 'customEvent', { name: sender.text, width: sender.getWidth() } ); } In the OnAjaxEvent of the button, I have the following:- if SameText(EventName, 'customEvent') then begin ShowMessage(Params['name'].AsString + ' ' + Params['width'].AsString); end; There is no message shown after the button is clicked. What am I missing here? This code is working, I don't know, maybe you are handling OnAjaxEvent events in another object. Quote Link to comment Share on other sites More sharing options...
Frederick Posted April 21, 2022 Share Posted April 21, 2022 51 minutes ago, Frederick said: In the OnAjaxEvent of the button, I have the following:- if SameText(EventName, 'customEvent') then begin ShowMessage(Params['name'].AsString + ' ' + Params['width'].AsString); end; I changed the following code and even the event name is not shown:- showmessage(EventName); { if SameText(EventName, 'customEvent') then begin ShowMessage(Params['name'].AsString + ' ' + Params['width'].AsString); end; } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 21, 2022 Share Posted April 21, 2022 Can you please make a simple testcase to check? Quote Link to comment Share on other sites More sharing options...
Frederick Posted April 21, 2022 Share Posted April 21, 2022 Sure, I'll attach one later. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 21, 2022 Share Posted April 21, 2022 Okay Quote Link to comment Share on other sites More sharing options...
Frederick Posted April 21, 2022 Share Posted April 21, 2022 Here is the testcase. Click on the TUniSpeedButton but there is no dialogue box displayed. The text in the TUniEdit control is copied to the clipboard however. ajaxreq.7z 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.