LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Return Ctrl-C from text box as a keypress event

I'd like to be able to process Ctrl-C as a keypress event from a text box, but the text box swallows up the keystroke as part of the "Cut" shortcut processing. Any way around this? I don't need clipboard support for the text box.
0 Kudos
Message 1 of 5
(3,883 Views)
You can catch control-c with a command button, not with a keypress event.
1. In the UIR editor, add a command button to your panel.
2. Edit the button and do the following:
2.1 Give it a callback function name.
2.2 Assign a Shortcut key: Modifier Key = MenuKey (Ctrl), Key = C
2.3 In the Quick Edit window, click on the paint brush, then right-click on the button, and click on the T in the lower-right corner of the palette to make the button transparent.
2.4 Delete the label.
3. Generate the callback function for the button. (Right-click on the button and select Generate Callback Function.
4. Edit the callback function and in the EVENT_COMMIT, add whatever code, if any, you want to execute on Ctrl-C. If you want to act on it only when Ctrl-C is pressed i
n the Textbox, call GetActiveCtrl to check if the Textbox is active.
See the attached example.
Message 2 of 5
(3,883 Views)
Step 2.3: The T for transparent is in the lower left corner on the palette, not the lower right.
0 Kudos
Message 3 of 5
(3,883 Views)
Regardless of whether or not you can trap Ctrl-C, I would recommend against doing anything to disable the Windows cut-and-paste. You may not think you need it within your application, but Windows users have become accustomed to it and may have uses that you don't anticipate like copying from your application to another application.
Unless the textbox will contain sensitive info like user names, passwords, account numbers, credit card numbers, etc., I would let them cut-and-paste as they please.
0 Kudos
Message 4 of 5
(3,883 Views)
In general, I would agree. In this instance, I'm coding a mini terminal emulator on a serial port of an avionics box. My users are accustomed to typing Ctrl-C to enter a particular mode when connected the serial port of the box.

I've since found another way around the problem. Thanks for your support and insightful comments.

-Mark Miller
0 Kudos
Message 5 of 5
(3,883 Views)