05-17-2016 09:54 AM
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
Solved! Go to Solution.
05-17-2016 10:15 AM
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.
05-17-2016 10:18 AM
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.
05-17-2016 10:30 AM
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.
05-17-2016 10:31 AM
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
05-17-2016 10:36 AM
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.
05-17-2016 10:37 AM
@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.
05-17-2016 10:38 AM
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.
05-17-2016 10:40 AM
@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!
05-17-2016 10:40 AM
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.