LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Key down event and boolean button value change event

Hello everyone,

I know how to do an event with key down using char but if I add to the same event a boolean button the option dissapears. My question is do you have an example of where an event is called when pressing a button or pressed a certain keyboard value?

 

Thank you

0 Kudos
Message 1 of 6
(424 Views)

The Event structure is designed to respond to a particular Event, at the time the Event occurs.  It is vanishingly unlikely that two Events, such as a Key Press and a change in the value of a Boolean control, would happen at exactly the same time (unless your CPU is running on a 10 millisecond cycle clock).

 

When you process an Event (say, a Key Down event), inside the Event Case you can make a decision about "what to do" by putting a Case Statement controlled by a Boolean, to do one thing if the Boolean is True (pressed) and something else if it is False, but it would be using the state of the control at the time the Key Down event happened, unless you put code inside the Key Down Event to, say, wait 2 seconds for the user to press a Boolean button and do one thing if True and another if False.

 

Bob Schor

0 Kudos
Message 2 of 6
(397 Views)

If several events share an event case, only event data nodes are available that a common to all events.

 

A boolean change does not have a "char", so once you add that, you can no longer have that event data node.

 

There are simple solutions to this, but I don't want to randomly guess what would be appropriate for your situation, because you have not give any details. What does the event do?

 

Once you share a simplified example of your code (VI, not a picture!) we can give further advice.

 

 

0 Kudos
Message 3 of 6
(391 Views)

Hi, in this case is for Log In. I want that the enter an the pressing the log in boolean to do the same. Thank you

0 Kudos
Message 4 of 6
(318 Views)

Assuming this is a string control, you can do the following:

 

  • Set the string to control to "limit to single line"
  • Create an event for "string:value changed" and "Log in button: value changed".
  • (No need to read key down events or event data nodes!)

If a string control is set to "limit to single line", pressing <enter> will accept the entry instead of inserting a new line into the control.

0 Kudos
Message 5 of 6
(301 Views)

@eneko.mujika wrote:

Hi, in this case is for Log In. I want that the enter an the pressing the log in boolean to do the same. Thank you


What is stopping you from making them separate events within the Event Structure? You can wire them up doing the same action.

 

I've attached a (very crude) example that could work for what you're wanting. I am sure other forum members can do better.

0 Kudos
Message 6 of 6
(291 Views)