LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XControl Operation

 

I have implemented a 3 position toggle switch using an XControl.

 

The positions are:

Up (Return to centre)

Centre

Down

 

Static positions for the switch are the down and centre. When the toggle switch is moved from the centre position to the up position, it will remain there as long as the left mouse button is held down. On release it snaps back to the centre position.

 

The toggle control uses a slide control for switching and a ring indicator to display the switch positions.

 

The control works as required with one exception.

If the switch is moved to the up position and the left mouse button is released it snaps back to the centre which is correct.

If however, the switch is moved to the up position and the mouse moved outside of the control, when the left mouse button is released the switch remains in the up position which is incorrect.

 

I use the ‘Mouse up’ event to detect the button release.

 

I think the reason this happens is because when the mouse is moved outside the XControl it looses focus and the ‘Mouse up’ event is not detected.

 

If this is the case then why when I select the up position, keep the left mouse button down, and move outside the XControl, can I still move the switch position to any position i.e. down centre or up. In this case the focus seems to still be on the XControl.

 

Is there something I am missing?

 

0 Kudos
Message 1 of 5
(3,446 Views)
It sounds like what you are seeing is an artifact of using a slide control as the base indicator for that part of the XControl. To do what you want you will also need to track the mouse position to make sure it is still over the control you moused down on.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,445 Views)

Hi Mike

 

Thanks for the post regarding my XControl issue.

 

I am not sure I understand why I need to track the mouse position.

 

I need the switch to snap back to the centre position when the left mouse is released regardless of the position of the mouse.

 

Just to clarify the operation.

 

  1. Mouse down on XControl (slide control)
  2. Move mouse (slide control) to up position, Switch displays up position (This works).
  3. Mouse up on XControl, Switch snaps back to centre position (This works) or Mouse up outside XControl, Switch snaps back to centre position (This does not work)

 

I did try using the slider ‘Mouse Leave’ event. When the mouse moved outside the XControl it did snap back to the centre, but then the switch reverted to the up position maybe because the mouse down was still active. This was not really going to be a solution as it should only snap back when the mouse button is released.

 

The reason this is an issue is that an operator can drag the switch from the down position to the up position, continue moving the mouse up i.e. outside the XControl, whilst holding the mouse down. Then when the operator releases the mouse button the expected snap back does not happen.

 

I would appreciate your thoughts,

 

Thanks

 

John Lee

0 Kudos
Message 3 of 5
(3,436 Views)

The idea is to use the mouse position to determine when you are no longer over the control. At that point you would execute the same logic as when you mouse up.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 5
(3,424 Views)

Mike

 

I now understand your suggestion to use the mouse positioning to implement the same logic as the mouse up when the mouse is no longer over the control.

 

I did implement this before using the slide control ‘Mouse Leave’ event. The switch did snap back to the centre position as the mouse drifted outside of the control.

 

There are two issues with this solution:

 

  1. This is not the intended operation of the switch. It should only snap back to the centre position on the mouse up action even if the mouse has drifted outside of the control.
  2. When the mouse drifts outside of the control and it has snapped back to the centre position, it then snaps back to the up position because the mouse down is still there even though it is outside of the control.

 

It appears to me that for the slide control within the XControl:

 

  1. When the mouse down event on the slide control is registered in LabVIEW, focus is locked on the slide control, allowing the value of the slide control to be changed even if the mouse is outside the control. This is maintained until mouse up.
  2. When mouse up occurs outside the slide control, focus is lost from the slide control and no ‘Mouse up’ event is detected.

 

I am not sure there is a solution to this. I will need to ponder on it.

 

Thanks again for the feedback,

 

John Lee

0 Kudos
Message 5 of 5
(3,408 Views)