This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CometWolf's profile picture

Disabling built in ctrl+v

Started by CometWolf, 19 June 2014 - 08:51 PM
CometWolf #1
Posted 19 June 2014 - 10:51 PM
I've recently been adding some ctrl+key shortcuts to my program, all of them work like a charm, with the exception of ctrl+v for pasting. Whenever ctrl+v is pressed in CC, it seems to queue the actual computer's clipboard as char events, instead of giving the key event as desired. Anyone know a way around this? I don't want to use a different key, as ctrl+v is pretty much the universal paste shortcut.
Lyqyd #2
Posted 19 June 2014 - 11:43 PM
In old versions, this is impossible. In the newer versions (1.6+), I have heard rumors of a "paste" event with clipboard contents, so that's worth looking into, if true.
Bomb Bloke #3
Posted 20 June 2014 - 05:57 AM
I get the impression he wants to paste the contents of his own clipboard.

As far as I can tell by just skimming the BIOS source and applying Occam's razor, other than returning the "real" system's clipboard alongside a single "paste" event (as opposed to multiple "char" events), it still works the same way under 1.6. But I could be wrong about that.

And if memory serves, it doesn't even return the entirety of the copied text - just the first line…
CometWolf #4
Posted 20 June 2014 - 06:40 AM
Indeed, i want my own clipboard. The issue though, is that there is no key event for pressing 'V' if ctrl is held. The char events would just get ignored anyways. However, using the paste event would indeed work. Sadly, im still on 1.58 :P/>
Bomb Bloke #5
Posted 20 June 2014 - 07:45 AM
Aaaaand now it occurs to me that the paste event would indeed do the job, even if it returns the "real" clipboard contents. My bad, Lyqyd.

Ok, so why not just look for a char event that wasn't preceeded by a key event? When you spot one, perform your internal paste process then flush out the rest of the event queue.
Edited on 20 June 2014 - 05:47 AM
CometWolf #6
Posted 20 June 2014 - 09:23 AM
I suspect that will only work if the person's clipboard actually contains text though. I'll have to do some testing later.
Bomb Bloke #7
Posted 20 June 2014 - 12:45 PM
Ugh, good point - you get no event at all if the system clipboard doesn't contain text. Ditto under 1.6.