Clear the clipboard
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Clear the clipboard
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
set the clipboardData["text"] to "" , and plain old
copy
- but the clipboard data remains as it was before.
Many thanks
This works for me:
Code: Select all
on mouseUp
set the clipboardData["text"] to ""
put the clipboardData
end mouseUp
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
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:
- 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 ?
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
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 ?
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)?
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
I don't know if this may cause any other side-effects, but a workaround to clear the clipboard on Windows may be:
(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")
Code: Select all
set the clipboardData["unicode"] to numToChar(0)
Hi,
What about this?
Best,
Mark
What about this?
I also tried this with repeat for each key, but that didn't work.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
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
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.
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
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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode