LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CTRL + V key pressing filtering

Hi all!
I need to do Copy/Paste (CTRL+C, CTRL+V) functions for Table Control, but built-in functions of LabVIEW work only for 1 cell and don;t work when you select region.
So i do it myself by filtering key-down? events and checking what key is pressed. The problem that if clipboard have some data and i press CTRL+V, LabVIEW don't send event "key down?", and execute Paste function itself.
0 Kudos
Message 1 of 9
(6,080 Views)
Here is a simple example. Does it help?

___________________
Try to take over the world!
Message 2 of 9
(6,063 Views)

Thanks, tst

It work perfect.

0 Kudos
Message 3 of 9
(6,050 Views)
Hi tst,
On my machine (Windows 2000, LabVIEW 7.1.1) your example does not work if I try to use the "key down?" filter event of one of the table controls. CTRL-C works like expected, but CTRL-V is not filtered and discarded and it is used the built-in paste functionality, working on only one cell.
Do you have any idea on how this could be?

I wanted to use a code like yours in a VI where I want to use my own cut&paste on one control but the orginal version on all the other controls. Thus, I cannot easily filter the key strokes of the whole VI scope....

Best regards

Arno
0 Kudos
Message 4 of 9
(6,024 Views)
My guess is that after you press Ctrl+C the control loses key focus. I tried getting it back programmatically, but didn't manage.
What you can do is have a case for Ctrl+V for the VI and use a flag to decide whether or not to paste. The flag will only be set when you use Ctrl+C on the table.

___________________
Try to take over the world!
0 Kudos
Message 5 of 9
(6,019 Views)
Thanks for this idea.
I now use a flag that is set when the CTRL-Key is pressed on the paste destination control. In the VI's KeyDown? filter event I then check whether the flag is set AND the char is "v" or "V" AND the PlatMods.Ctrl is TRUE.
If now the CTRL+V key sequence is started first the control's KeyDown? event sets the flag and subsequently the VI's KeyDown? event does the paste.
This seems to work.
0 Kudos
Message 6 of 9
(6,015 Views)


@Arno Euteneuer wrote:
I then check whether the flag is set AND the char is "v" or "V"...

That's why I used the scancode which identifies the "V" key (at least in XP).

BTW, a better way might be to detect the key down event for the target control. That way you would need to select, copy, select where to paste and paste. That seemed to have been the original idea I had when I did the example because the EditPos property is taken from the target table. That way, you won't have to bother with flags and such.
If you use the Clipboard VIs which are floating around, you could probably even do this through the clipboard and get data from e.g. Excel.


___________________
Try to take over the world!
0 Kudos
Message 7 of 9
(6,009 Views)


@tst wrote:


@Arno Euteneuer wrote:
I then check whether the flag is set AND the char is "v" or "V"...

That's why I used the scancode which identifies the "V" key (at least in XP).


I would like to make one correction - it occured to me that the scan code is probably different for different keyboards (if I understand the help file correctly) in which case checking for the ASCII values is the right way to go.

___________________
Try to take over the world!
0 Kudos
Message 8 of 9
(6,002 Views)



That's why I used the scancode which identifies the "V" key (at least in XP).


I recognized that but was unsure about on what the scancode may depend (hardware, OS ?). But maybe you're right and this is the easier implementation.



BTW, a better way might be to detect the key down event for the target control. That way you would need to select, copy, select where to paste and paste. That seemed to have been the original idea I had when I did the example because the EditPos property is taken from the target table. That way, you won't have to bother with flags and such.
If you use the Clipboard VIs which are floating around, you could probably even do this through the clipboard and get data from e.g. Excel.



Actually, using the Clipboard VIs and stuff from other applications is what I do. In my case the target control is a string control used as kind of a HyperTerminal. I filter and discard all the KeyDown events from this control and send everything being of type ASCII to a serial interface. A second independent loop collects all characters coming from the interface and adds them to the string indicator (with some cursor handling for escape characters). So, pasting in my case is done by getting a string from the (Windows) clipboard and sending it to the serial interface. On the other hand there are some more string indicators on the same front panel where the standard paste is to be used. So, I think setting the flag for this one very special indicator is maybe the only possibility.

Best regards

Arno



0 Kudos
Message 9 of 9
(6,000 Views)