LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse down? Event discard not working

Solved!
Go to solution

Dear Community,

 

Please could you help me work out why the Mouse down? Event isn't being discarded in the following code. I have stripped out all but the pertinent controls. It should be that mouse clicking on a control with left middle or right mouse buttons returns the name of the control and the button it was clicked with (which it does), but NOT when the Lock Boolean is True.

 

However, it seems to be ignoring the value of the lock boolean?

 

Please help me understand what I have done wrong here.

 

Many thanks in advance,

R Gibbs

0 Kudos
Message 1 of 10
(5,045 Views)
Solution
Accepted by topic author rg8766

The actions in the Filter Event are performed regardless.  If you add another case for "Value Change" or "Mouse Down" for all of those buttons, they will not be triggered when the lock is set to TRUE.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 10
(5,034 Views)
Solution
Accepted by topic author rg8766

You discarded that the mouse down occurred.  So if anything else would have been affected at an OS level, the mouse down would have been ignored.

 

Alll of the other stuff that occurred in the event case still executes.  What you need to do is put that in a case structure.

Message 3 of 10
(5,030 Views)

You are not discarding the event (or whaever you do in it), but are discarding the mouse action from being relayed to the UI and OS (i.e. you cannot click in the controls for entering values if mouse down events are discarded). BIg difference.

 

If you want to prevent users from entering data at certain times, you should play with the "disabled property" instead.

Where is the rest of the code? What are you actually trying to do? I see the potential for race condition.

 

 

0 Kudos
Message 4 of 10
(5,021 Views)

Thank you to you both for such prompt replys.

 

I can see that both setting a Mouse Down? filter event in addition to the Mouse Down event, or using a case structure to disable the code within the event structure, are both valid solutions. With the number of controls I am using the case structure works best for me in this case.

 

What confused me is the following example I got from NI which has the code for the event and the lock boolean in the same event case, so not sure why it works in that example.

 

Thanks again.

 

RG

0 Kudos
Message 5 of 10
(5,018 Views)

The key down event was discarded.  It didn't pass the key down to the OS which kept it from being entered into the string control.  The rest of the code still ran.

 

Your mouse down event was also discarded.  It kept the OS from taking it.  (If it hadn't, the result would be the cursor showing up in the indicator.)  The rest of the code still ran.

 

Both behaved exactly like they were programmed to.

0 Kudos
Message 6 of 10
(5,006 Views)

@rg8766 wrote:

What confused me is the following example I got from NI which has the code for the event and the lock boolean in the same event case, so not sure why it works in that example.

 


What is cofusing to you? Seems to work perfectly and very similar to your example.

 

The boolean is changed with the mouse, not a key, so key down event are irrelevant for that

Also not that this example uses a global "key down?" event, not anything tied to a particular control.

 

0 Kudos
Message 7 of 10
(5,004 Views)

Dear Sir,

 

I have used the Disable property on the control, which prevents direct numerical entry - but does not actually seem to prevent a Mouse Down event from being registered to that control, hence the need to handle the event structure separately.

0 Kudos
Message 8 of 10
(5,003 Views)

@rg8766 wrote:

 

I have used the Disable property on the control, which prevents direct numerical entry - but does not actually seem to prevent a Mouse Down event from being registered to that control, hence the need to handle the event structure separately.


What is the purpose of all this? Can you give us some background information?

Maybe there are much better ways to achieve whatever you are trying to do. Just ask!

0 Kudos
Message 9 of 10
(4,997 Views)

Do you really need to use the mouse down event?

 

I don't think I've ever used it in any of my code.  Often when someone is trying to use a mouse down event, they are trying to do it with buttons.  And the value change event is a far more appropriate event to use with them.

 

It think handling mouse down events are appropriate if you are trying to simulate some sort of drag and drop functionality.  But I don't see anything in your code that is similar to that.

0 Kudos
Message 10 of 10
(4,995 Views)