Clear the clipboard

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Clear the clipboard

Post by bonbon » Sat Oct 18, 2008 12:02 pm

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sat Oct 18, 2008 12:10 pm

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

bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Post by bonbon » Sat Oct 18, 2008 12:57 pm

Thanks for the quick reply. It's not quite emptying the clipboard, but if there is no other way, a single space will do.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sat Oct 18, 2008 6:01 pm

there's no space there, it's empty. I was implying that there must be some other problem somewhere...
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Post by bonbon » Sat Oct 18, 2008 8:55 pm

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 ?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sat Oct 18, 2008 9:19 pm

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

bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Post by bonbon » Sat Oct 18, 2008 10:02 pm

I'm using Windows XP Home, service pack 2. Thanks for taking the time to look at this - maybe it is a Windows oddity ?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sat Oct 18, 2008 10:43 pm

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.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sat Oct 18, 2008 11:05 pm

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.

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sat Oct 18, 2008 11:19 pm

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")

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Oct 19, 2008 12:48 am

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
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

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sun Oct 19, 2008 9:54 am

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.

bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Post by bonbon » Sun Oct 19, 2008 11:04 am

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".

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Oct 19, 2008 2:51 pm

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
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

Post Reply