LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering an event from a Menu Ring when the user selects the same item

Solved!
Go to solution

Like the subject says:  I have a menu ring.  I want to trigger an event if the user clicks on a menu item that is the same value it currently has.

 

I considered dynamically registering on "Ring: Mouse Down", then pulling value from that - but I can't figure out how to tell if they clicked inside or outside the menu box. I also can't assume the menu box it pops up is always the same size because I'm programmatically setting the values of the ring.

 

Any thoughts?

Message 1 of 15
(4,285 Views)

Use a "mouse up" event on the control, then read the value.

0 Kudos
Message 2 of 15
(4,283 Views)

@altenbach wrote:

Use a "mouse up" event on the control, then read the value.


 

I tried that - it doesn't work... unless I'm missing something.

 

Edit: To be more specific, the "mouse up" event never triggers.  Mouse Down changes the focus from the control to the menu, which (it would apper) are different items.  Similarly, the "Ring: Mouse Down" event only triggers when clicking the control itself, never when clicking the menu.

0 Kudos
Message 3 of 15
(4,274 Views)

Can you switch to an enumerator? Using an enumerator and the Mouse Leave event will give you the desired effect. 

0 Kudos
Message 4 of 15
(4,255 Views)

Sorry, posting by phone. Typically an event should only happen when the value changes, what's your use case here?

You could have a dummy entry on top (e.g. "please select") and reset to that after each selection event. Now the value always changes and you can use a plian "value changed" event.

0 Kudos
Message 5 of 15
(4,252 Views)

 


@Citabria wrote:

Can you switch to an enumerator? Using an enumerator and the Mouse Leave event will give you the desired effect. 



I tried "Mouse Leave" with the Ring.  It didn't work.  After a quick test, the Enumerator acts the exact same way -  "Mouse Leave" triggers the moment you click.

0 Kudos
Message 6 of 15
(4,240 Views)

@altenbach wrote:

Sorry, posting by phone. Typically an event should only happen when the value changes, what's your use case here?

You could have a dummy entry on top (e.g. "please select") and reset to that after each selection event. Now the value always changes and you can use a plian "value changed" event.


I considered adding the dummy, but I don't want it. It will work, but it is clunky, and I don't like building clunky GUIs 😛   If the user wants to add the same thing twice from a fairly large list, I don't want them to have to scroll down through the entire list and find it again - especially if they are doing this several times in a row.

 

As for what my use case:  not relevant.  I fully realize that there are several different ways to design the program - in fact, I have considered them.  However, this is the one that will feel most natural to my users.  I don't want to switch unless this is flat impossible.

0 Kudos
Message 7 of 15
(4,231 Views)
Solution
Accepted by topic author BowenM

That shed some light on the issue. Use a Combo Box. Any selection in a combo box is always a value change so you can use the Value Change event and capture the same selection twice. I tried it and this works. Selected "Test 1" over and over again and it always triggers Value Change.

 

 

Message 8 of 15
(4,218 Views)

Huh.  I didn't think combo box would act differently. I wanted the numeric of the Ring or Enum, but I can convert back and forth between string and make this work.  Thanks.

0 Kudos
Message 9 of 15
(4,212 Views)

You can do what Altenbach says adding the dummy state.  And add a Mouse Down event to cause it to Reinit to Default and a Value Change to catch the new value.  This works for me on a menu ring, even when selecting the same value.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 10 of 15
(4,201 Views)