Jump to content

Recommended Posts

Posted

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
  • 1 year later...
Posted
  btnCopy.ClientEvents.ExtEvents.Values['click']:='function tap(sender, e, eOpts) '+

      ' { '+

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

      ' copyText.select(); ' +

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

      ' }';

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

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 ?

 

 

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

Posted

 

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.

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

Posted
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

Posted
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. 

 

Posted

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?

Posted
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.

Posted
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;

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...