LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event when ring control menu closes

I am planning to use a ring control in my VI and will programmatically open the control's drop down menu (list of ring items) at a certain time.  The menu closes if the user selects an item from the list and also if the user clicks somewhere else on the VIs panel or outside the panel.  If the user has selected an item from the list that causes the rings value to change, then a value change event will occur, but if they did not change the value such as by just clicking outside the menu, then a value change event does not occur.  How can the closing of the menu be detected if the control's value has not changed?  It would be nice if there is an event that can be used to detect this.

0 Kudos
Message 1 of 8
(3,042 Views)

The first question is of course - what are you trying to do, why do you need to detect this?

Maybe alternative can be suggested by the users of this forum.

 

To solve your specific question I'd like some more details:

When do you open the menu? Can you make any predictions on the program state, mouse cursor position, etc. that you can exploit to solve your problem?

 

If you can post your VI(s) please do so. It will be really hard to help you otherwise.

 

Regards Florian

0 Kudos
Message 2 of 8
(3,026 Views)

Here is some additional information about how the ring control is to be used.  The ring control is to be used as an element of an XControl that I am trying to make.  The XControl is a customized button to silence an audible alarm.  The button is based on a boolean with some added functionality.  It should behave as follows:

 

  • If the button state is false, and the user clicks the button briefly, then the button will change to the true state and the alarm will be silenced for a default time.
  • If the button state is false, and the user clicks and holds the button for more than 2 seconds, then the user will be given a list of silence times to select from.  The user can then change the silence time from the default time to some other time.  Once the time is selected, the button state will change to true and the alarm will be silenced for the time that the user selected.  I was thinking of using a ring control to allow the user to select the silence time.  It would initially be invisible and would become visible after the 2 second hold time and its menu would drop down showing the user the list of silence times to choose from.  If the user clicked outside the menu, the default time would be used.
  • If the button state is true and the user clicks the button, then it will change to false and the alarm will be unsilenced.
  • If the button state is true and the silence time expires, then the button state will change to false and the alarm will be unsilenced.

I was thinking of trying to detect when the menu closed (user had either selected an item from the ring control or closed the menu by clicking elsewhere) by giving it focus when the menu is dropped down and then checking for when the ring control lost focus, but this seems to have problems.  Focus does not change when the user selects an item from the menu if that item was already selected.  In this case, the ring retains focus and its value doesn't change either.  How can I tell it was clicked?

 

I don't have code yet that I can attach.

 

Darin

0 Kudos
Message 3 of 8
(3,007 Views)

That was extensive, thanks.

If it all comes down to "was it clicked?" couldn't you use the mouse button pressed event? Maybe a combination of that and the options you already mentioned, so you cover all cases.

Like: Give it focus, if it looses focus the user clicked elsewhere, if mouse button pressed the user selected something.

 

Regards Florian

0 Kudos
Message 4 of 8
(2,984 Views)

Have you considered using a run-time shortcut menu to allow the user to select the time by right clicking on the button?

Similar functionality, but much easier to implement,

 

0 Kudos
Message 5 of 8
(2,976 Views)

Hi Florian,

I thought that it might work to check for a mouse click event on the ring menu, but it turns out that no such event is generated.  If you click on the ring control when the menu is closed, you get a mouse down for the ring control, but if you click on the menu when it is open, you don't get a mouse down for the ring control.  Too bad, that would have been a useful solution.

 

Darin

0 Kudos
Message 6 of 8
(2,963 Views)

I have tried using a shortcut menu, but that has some limitations.  If the user clicks somewhere else other than on the menu, the menu closes without generating any event.  For instance, if the shortcut menu is open and I press the <alt> key, the menu closes, but no event is generated and focus is not changed if some control has focus.

 

 

0 Kudos
Message 7 of 8
(2,957 Views)
Well, I guess you could track the position of the mouse after the button has been clicked and maybe fire a user event when it moved outside the boundary of the ring control, or set a flag if it moves outside the control and fire an event on detecting a mouse down when the flag is set. Or how about using another vi with a ring control? You can control it's position, open and close it's front panel to control visibility and there are events for mouse enter and leave both for the panel and the vi itself. A user event in the calling vi could be fired from the pop-up vi. M
0 Kudos
Message 8 of 8
(2,947 Views)