Uidoc.copy does not work as expected

The user marks two words (a name) with mousecursor in the ‘source’ field. My intention is, to transfer this marked text to another field ‘target’. All Fields are plain text.

Notes documentation says that uidoc.copy takes text that is marked in edit mode. Here an extract of original documentation:

Copies the current selection in a document to the Clipboard. The current selection can be anything on the document, such as text or graphics.

I’ve put this script under a botton:
… Call uidoc.Copy Call uidoc.GotoField(“target”) Call uidoc.Paste
This does not work, an error occurs. Error message: Only text can be pasted into this type of field.

Does anyone have another idea to solve this issue ?

Hint: The following works. After that, target has the content of source:
Call uidoc.GotoField(“source”) Call uidoc.SelectAll Call uidoc.Copy Call uidoc.GotoField(“target”) Call uidoc.Paste

Subject: Focus

Seems to me that when click the button the text you had ‘marked’ (which i ASSume means it has the selection focus) will lose that selection focus (ie, no longer be ‘marked’) when you click the button to invoke the copy

Subject: The copy may’ve caught more than text.

I’ve run into things like this when I copy the table enclosing some of the text, or the table cells.

Subject: Thank you for the answers

@Mike:

They are plain text fields, as mentioned

@Bob:

That sounds plausible. But then, this function is absurd, because i don’t know whow to invoke it without a button.

Subject: Reason found

I found out that a button in fact changes the focus to itself. That is the reason for that behaviour.

A possible solution is to use an Action which leaves the focus where it is.