LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Key input on VI and Control

Hi,

 

I want to make a short key for a control even in out of focus.

In out of focus in the control, the key input can be treated in "Key down" event and position the cursor to (0,0) and editing mode of in-focus.

For in-focus case, the key input in "Control-Key down" event and intend to move the cursor.

 

My trouble is any key input direct to only VI key input not Control.

 

Can you open the attachement?

0 Kudos
Message 1 of 4
(2,629 Views)

(For those who haven't tried opening the VI, it is 2009.) 

 

Hi labmaster

 

You have not defined what is "in focus", this makes it difficult.

For the out of focus event, you can get focus by using the key navigation properties of the control.

 

Alternatively I suggest you:

1) Either add 2 boolean controls to your fron panel (hidden) and toggle on "Key down" & "Ctrl Key down" for the selected key, e.g. F2 to position the cursor.

2) Use the Aquire Keyboard Keys pressed functions from the Connectivity pallette to determine which keys have been pressed (you won't need the event structure then - I don't think)

 

Setting the key focus to cell 0,0 needs some work. - if you make a boolean indicator change state when the functions do the correct thing, then you know you have the correct toggle code and can work on the table focus code.

 

Change the Boolean constant in your While loop to a Stop button.

Using the Abort button is no way to stop a VI.

 

I'm not going to do it all for you or post a VI as if you do it yourself I'm sure you'll apppreciate the learning exercise.

 

James

 

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 2 of 4
(2,597 Views)

Thanks for the reply.

I had better explain about my intention.

 

My original thinking was when I pressed "F2" (in out of focus), make state infocus and then positioned the cursor to (0,0) with editing mode automatically.

Then press "F2" one more time, the cusor is expected to move the next cell.

 

So that was the reason why I asked how to distinguish key inputs from between VI and Table control.

 

labmaster.

0 Kudos
Message 3 of 4
(2,586 Views)

I don't know how you created the Table in your vi, but it would not respond to property nodes for selection.  So I created a new table and changed the code to do part of what you want.  The Key Down event checks for the F2 key.  If so, then is uses Property Nodes to set the selection start and selection size.  When you press F2, regardless of who has focus, the first row, first column (0,0) will be selected.  To move to the next cell when pressing F2 again, you will have to add code to set the selection start to (0,1).  The best way to do this is to keep track of the selection row and column in a shift register, and increment the column on each F2 press.  Initialize the shift register for column to -1 so that the first time F2 is pressed, it gets incremented to 0.  You will have to check when the end of the row is reached, then increment to column 0 of the next row.  I will leave it up to you to code this part.  Good practice.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 4
(2,562 Views)