LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Double effect when monitoring events of UP and DOWN keys

Solved!
Go to solution

This is a simple VI. If the UP or Down key is clicked the value counter is increased/decreased.

 

260702_ArrowUpDownTest_FP.png260702_ArrowUpDownTest_BD.png

 

There is control Numeric. The operator can place cursor in this control and increase/decrease its value with the same two keys. There is a side effect. The value of counter is also changed.

 

Is there any way to prevent counter from changing its value when operator uses keys to set value of another numeric control?

Note: This VI only illustrates my question. The real GUI has many numeric controls. Thus monitoring of each numeric control is out of question.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 1 of 13
(1,603 Views)

Hi Y,

 


@_Y_ wrote:

Is there any way to prevent counter from changing its value when operator uses keys to set value of another numeric control?


So you create an event case where you wait for ANY "key up" event and when it is the UP key you increase that "counter".

I don't see any "side effect": the event case does exactly what you have programmed to do!

 


@_Y_ wrote:

There is a side effect. The value of counter is also changed.


Remove the code that increments the "counter"…

 

Different question: when do you REALLY want to increment this "counter"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(1,584 Views)

I'm not sure what is your goal you're trying to achieve, but it sounds like you need to discard the key event. Maybe this approach would work, at least as an idea:

snippet.png

Message 3 of 13
(1,571 Views)

@_Y_ wrote:

The operator can place cursor in this control and increase/decrease its value with the same two keys.


You don't need code for that. The control already supports this behavior. If the control has focus, depending on where the cursor is (which you can control with the left/right keys or the mouse), different digits will be incremented or decremented when you press the up/down keys.

 


___________________
Try to take over the world!
0 Kudos
Message 4 of 13
(1,553 Views)
 wrote:

Hi Y,

 

Different question: when do you REALLY want to increment this "counter"?


Probably I shall reformulate the question.

 

I need to monitor use of UP and DOWN keys if they are not used for direct control of numeric values. 

or

I need to monitor use of UP and DOWN keys if no numeric control has forcus. 

 


@Andrey_Dmitriev wrote:

 it sounds like you need to discard the key event.


If I discard the event, the operator cannot use the same key for setting values in Numeric

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 5 of 13
(1,550 Views)

@_Y_ wrote:

 


If I discard the event, the operator cannot use the same key for setting values in Numeric.  Is there any way to prevent counter from changing its value when operator uses keys to set value of another numeric control?


Well, if the "another" is key word in this task, then may be switch to Key Up from control and check reference, from which is it triggered?:

snippet2.png

0 Kudos
Message 6 of 13
(1,536 Views)

@Andrey_Dmitriev wrote:
switch to Key Up from control and check reference, from which is it triggered?

If I understand it correctly, this will require setting focus to certain control. But I want to avoid it. 

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 7 of 13
(1,528 Views)
Solution
Accepted by topic author _Y_

@_Y_ wrote:
 wrote:

Hi Y,

 

Different question: when do you REALLY want to increment this "counter"?


Probably I shall reformulate the question.

 

I need to monitor use of UP and DOWN keys if they are not used for direct control of numeric values. 

or

I need to monitor use of UP and DOWN keys if no numeric control has forcus. 

 


@Andrey_Dmitriev wrote:

 it sounds like you need to discard the key event.


If I discard the event, the operator cannot use the same key for setting values in Numeric


Does this cover all cases? I forgot to remove the strict qualifier, but otherwise may cut it.

 

snip_numeric_control_key_up.png

 

Message 8 of 13
(1,520 Views)

Hi Y,

 


@_Y_ wrote:
 wrote:

Hi Y,

 

Different question: when do you REALLY want to increment this "counter"?


Probably I shall reformulate the question.

 

I need to monitor use of UP and DOWN keys if they are not used for direct control of numeric values. 

or

I need to monitor use of UP and DOWN keys if no numeric control has forcus. 


Part of being a good/better programmer is the ability to describe code requirements with all needed details.

You forgot that "if" in your initial message…

 

All you need to do is to implement the "if" in your code!

On the "key focus" property: you could create an user event that handles all your numeric controls. Whenever any of the controls get focus you could set a flag and when the controls lose focus you clear the flag. Use that flag for your "if" condition…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 13
(1,509 Views)

@cordm wrote:


Does this cover all cases?


Thank you, it does the work.

 

Shame on me. I don't like error-driven logic and always forget to think in its way.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 10 of 13
(1,477 Views)