Clipboard

Is there any control or functionality in Natural for Ajax to get access to the clipboard?

BR,
Hermann

Hi Hermann,

what do you want to do with the clipboard? From where do you want to access it? Do you want to implement a custom control with cliboard access?

Or do you just want to copy the contents of the clipboard into some input controls like FIELD/TEXT* …?

Best Regards,
Christine

Hi Christine,

in principle I want to the copy the clipboard to a TEXT-control - but I want to verify the content before pasting

therefore I want to add a button “copy from clipboard” or something like this and then analyse the content before filling the TEXT-control

BR,
Hermann

Hi Hermann,

you can access the clipboard from JavaScript. To do so, you can write a very simple custom control. The custom control would just be a button. When the button is clicked you can access the clipboard content via the JavaScript function parent.window.clipboardData.getData(…).

You can then use the setPropertyValue(…) function of the NJX JavaScript framework to fill the modified value into the property of your TEXT control.

The chapter “Custom Controls” of the NJX documenation contains more information on how to write custom controls. The njxdemos contain simple examples.

A clipboard custom control woul be a very simple and small custom control. Still, you need to get familiar with the concept of custom conrols first.

Best Regards,
Christine

Hi Christina,

thanks for your infos - I’ll have a look at the NJX documentation.

BR,
Hermann

Hi Christine,

I had a look at the documentation and more questions than before :slight_smile:

I modified controllibraries and added:
<library prefix=“sitc”

I created and layout editor extension: editor_sit.xml
and created a control sitc:clipboardtostring

But how to proceed?
Where to define how the button looks like?
Where to add the JavaScript function parent.window.clipboardData.getData(…) you mentioned?
Is there any functionality in Application designer which can be used?

BR,
Hermann

Hi Hermann,

For this control you need to add JavaScript functionality. What you did up to now is making the control usable in layouts. But up to now the control does not have own functionality. This would be enough if you are just building a Macro control from existing controls. Your control has additional JavaScript functionality, that’s why you need to do the following:

Write a Tag handler for your control. In the Natural Ajax Demos you’ll find an example how to write a custom control with own JavaScript:
Page layout is customcontrols3.xml
Natural program is CUSTC3-P

Maybe this would be a good starting point to write your handler. You could copy the handler, rename it to CLIPBOARDTOSTRINGHandler and adapt the html/javascript. You’ll find the example tag handlers of the Natural Ajax Demos in the src subfolder of the njxdemos user interface component.

The relevant documentation chapter for your example is: http://techcommunity.softwareag.com/ecosystem/documentation/natural/njx835/custcontrols/CreatingNewControls.htm#CreatingNewControls

Please let me know if this helped you to program your control.

Best Regards,
Christine