Jump to content

dbmemo.SelectAll and dbmemo.CopyToClipboard


mierlp

Recommended Posts

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(); ');
  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  btnCopy.ClientEvents.ExtEvents.Values['click']:='function tap(sender, e, eOpts) '+

      ' { '+

      'var copyText = document.getElementById("'+UnimMemoCopy.JSName+'_id-inputEl");' +

      ' copyText.select(); ' +

      'document.execCommand("Copy");' +

      ' }';

Link to comment
Share on other sites

  • 9 months later...
  • 6 months later...

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 ?

 

 

Link to comment
Share on other sites

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?!

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

  • 2 years later...
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)

Link to comment
Share on other sites

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()?

jsalert.png

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...