Page 1 of 1
Clear the clipboard
Posted: Sat Oct 18, 2008 12:02 pm
by bonbon
Another beginner's question ... please could someone tell me how to empty the clipboard ? I've tried:
set the clipboardData["text"] to "" , and plain old
copy
- but the clipboard data remains as it was before.
Many thanks
Posted: Sat Oct 18, 2008 12:10 pm
by BvG
This works for me:
Code: Select all
on mouseUp
set the clipboardData["text"] to ""
put the clipboardData
end mouseUp
Posted: Sat Oct 18, 2008 12:57 pm
by bonbon
Thanks for the quick reply. It's not quite emptying the clipboard, but if there is no other way, a single space will do.
Posted: Sat Oct 18, 2008 6:01 pm
by BvG
there's no space there, it's empty. I was implying that there must be some other problem somewhere...
Posted: Sat Oct 18, 2008 8:55 pm
by bonbon
Hmm ... I've now tried this (with no space between the double quotes) on a new MainStack, which has nothing more than a Copy button, a Paste button, and a Scrolling Field. The Paste button code is just "paste".
The Copy code is:
Code: Select all
on mouseUp
if the selectedText is empty then
set the clipboardData["text"] to ""
answer "It's empty"
else
copy
answer "There's something in it"
end if
end mouseUp
- and I also tried it with the suggested "put the clipboardData" line after the "set" command.
If I type in a short sentence, highlight a word, and press Copy, it tells me there's something in it, and I can then paste the copied word wherever I want.
If I then make sure nothing is selected, and press Copy again, it tells me it's empty, but a click on the Paste button brings back whatever was in the clipboard previously.
I'm probably doing something daft, but I can't see what. Any ideas ?
Posted: Sat Oct 18, 2008 9:19 pm
by BvG
I just can't reproduce your findings. Using exactly the same setup you describe, I do get empty pasting when expected. What OS are you on (clipboard does depend a bit on the OS APIs)?
Posted: Sat Oct 18, 2008 10:02 pm
by bonbon
I'm using Windows XP Home, service pack 2. Thanks for taking the time to look at this - maybe it is a Windows oddity ?
Posted: Sat Oct 18, 2008 10:43 pm
by BvG
I'm on OS X, and if you did this in a fresh IDE (no third party apps, recently started) then it's a bug, and should be filed in the quality center.
Posted: Sat Oct 18, 2008 11:05 pm
by SparkOut
Behaves like that on my XP machine too. Setting the clipboardData to empty, setting the clipboardData["text"] to empty or setting the clipboardData to tEmptyArray all failed to clear the clipboard.
Posted: Sat Oct 18, 2008 11:19 pm
by SparkOut
I don't know if this may cause any other side-effects, but a workaround to clear the clipboard on Windows may be:
Code: Select all
set the clipboardData["unicode"] to numToChar(0)
(setting the clipboardData["text"] to numToChar(0) doesn't work, but forcing it to set the null ascii char in unicode seems to stop anything being pasted. Interrogating "the clipboard" or "clipboard()" functions will return "text" though, not "empty")
Posted: Sun Oct 19, 2008 12:48 am
by Mark
Hi,
What about this?
on foo
put the keys of the clipboarddata into myKeys
repeat for each line myClip in myKeys
set the clipboardData[myClip] to empty
end repeat
end foo
I also tried this with repeat for each key, but that didn't work.
Best,
Mark
Posted: Sun Oct 19, 2008 9:54 am
by SparkOut
I don't know if you mean to suggest that code would work or not Mark, but it doesn't work on my system. I already tried setting keys of an "empty" array too - it seems on Windows (XP at least) that the clipboardData is not being set to empty whatever you do. The "unicode" null char workaround seems to be the only thing I've found at the moment that might do any good.
Posted: Sun Oct 19, 2008 11:04 am
by bonbon
Thanks to everyone for their input.
I have submitted this as a bug to the Quality Control Centre. As the "unicode" workaround seems to work (and many thanks for that), I gave the bug a severity of "minor".
Posted: Sun Oct 19, 2008 2:51 pm
by Mark
Hi Sparkout,
Setting the clipboarddata to NULL really does nothing but that. When paste unicode, you will get a NULL character. Although you won't notice this in many applications, it might cause big trouble in unicode compatible applications.
Best,
Mark