How to copy the entered text in dialog with button from code?

835 views Asked by At

I want to copy the text in DialogBox in my clipboard from code after button click.

I need in my dialog a button with function ctrl+c .

I have this code for my Dialog:

Dialog      dialog;
DialogField dialogField;
str string;
;
dialog = new Dialog("My personal dialog");
dialogField= dialog.addFieldvalue(extendedTypeStr(String30), string, "insert the text to be copied");

// ctrl + c button
//I need a button  with the function to copy the text entered
dialog.run();
if (dialog.closedOk())
{
}
}

Thanks for help,

enjoy!

1

There are 1 answers

6
Jan B. Kjeldsen On BEST ANSWER

Check the TextBuffer.fromClipboard method.

Example use:

TextBuffer txtb = new textBuffer(); 
#define.ExampleFile(@"c:\test.txt") 
#define.ExampleOpenMode("w") 

// Set code access permission to help protect the use of TextBuffer.tofile 
new FileIoPermission(#ExampleFile, #ExampleOpenMode).assert(); 

if ( txtb.fromClipboard() ) 
{ 
    // Got text from clipboard - save it to file 
    txtb.toFile(#ExampleFile); 
} 

// Close the code access permission scope. 
CodeAccessPermission::revertAssert(); 

It should be easy to adapt to a dialog.