LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to prevent an enum control from wraping around

Unless I'm misunderstanding the problem, you guys aren't trying hard enough (or are unaware of super secret event structure features).  Attached is a VI that when ran won't allow you to go from the last item to the first, or first to last if you click on the up and down arrows, but will let you pick any item if you select it from the drop down.

 

I wasn't sure how to handle things like using the arrow keys if you tabbed into the control so for now you can't change its value this way.

 

EDIT:  Okay at the moment it doesn't work perfect if only two items exist.  You can still use a mouse, but not the arrow keys, I think this could be fixed.

 

DOUBLE EDIT:  Okay here is a simplier version, but I don't think I could handle the two item option without some work on mouse location, or adding two buttons, one for up and one for down.

Download All
Message 11 of 24
(1,336 Views)

Disable the first or last item in the list and it wraps around.  Either version.

 

Lynn.

0 Kudos
Message 12 of 24
(1,321 Views)

@johnsold wrote:

Disable the first or last item in the list and it wraps around.  Either version.


Okay add code to detect what items are disabled.  Either way this solution is possible.  Also the OP never mentioned anything about disabled items.

0 Kudos
Message 13 of 24
(1,315 Views)

Okay a few minor changes and improvements, now it supports key navigation (with up and down arrow keys if you tab into it) and it works with items that are disabled.  So if you disable the last item, you can't get to it, but pressing down also won't wrap around.  It also functions as you would expect if there are only two items, allowing you to go in one direction only.

 

I did go the cheap route, and decide which button was being pressed by looking at the mouse location of Mouse Down, and similarly detecting if the Down key was being pressed when the key focus was on the control.

0 Kudos
Message 14 of 24
(1,308 Views)

Now go and fix the direction too! 

 

That's been bothering me for years.


"Should be" isn't "Is" -Jay
0 Kudos
Message 15 of 24
(1,265 Views)

I gave you a kudo because I think it should be an option to have up increment the value of the numeric, or up move up in the list of items.  But personally I like it the way it is.

0 Kudos
Message 16 of 24
(1,243 Views)

Any chance of a LV 2012 version.

0 Kudos
Message 17 of 24
(1,226 Views)

@Intaris wrote:

Any chance of a LV 2012 version.


Here it is saved in 2011, but you know what is interesting is it doesn't work as well in 2011 or 2012, as it does in 2013, and I'm not sure why.

 

If you click the down arrow in 2013 over and over it never wraps around.  But in 2011 or 2012 if you press it fast enough it jumps to the second value.  Same with if you tab into the control and press down.  In 2013 if you press it quickly nothing happens.  But if you hold the down key, pressing it crazy fast, it does wrap around.  In 2011 and 2012 you can make it wrap just by pressing down a couple times quickly.

 

If I had to guess I'd say this has something to do with the value being changed twice before handling it the first time.  But I'm not sure how this can happen since each event has the "Lock Panel" in the event.

0 Kudos
Message 18 of 24
(1,211 Views)

Hello everybody,

 

and thank you for all your input to my question.

I found another solution, that is simply making a menu ring out of the enum control which is fine in one of my cases. In another I used something inspired by Hoovahh's vi.

 

@Intaris: Please can you post how to disable the click and hold function (for this one control hopefully) - thanks

 

Thanks again

 

Martin

 

0 Kudos
Message 19 of 24
(1,200 Views)

Hmm, no cigar sorry.  It doesn't fulfil one of our criteria.

 

If I register for an event on the control in question in a parallel loop, the parallel loop should not receive and spurious values via Events.  It does.  This is because the events are still generated with the "new" and unvetted values whereas writing to a local does NOT generate an event.

 

If I was limited to a single loop, the problem would indeed be a much simpler one.

0 Kudos
Message 20 of 24
(1,190 Views)