Jump to content

Intercepting slide range change


Recommended Posts

Troubleshoot it. I have simply intercepted the key down event, the mouse leave event and also the mouse down event. Inside those events I get the new range of the control from its property nodes scale.minimum and scale.maximum and check if they are different from saved values on the shift register of the event-loop. It works good.

Link to comment

Another variation that works for almost all similar situations is to have a separate loop that just polls every 100ms or so, comparing the last known value (in shift register) to the current value. If it detects a change in the value, then it fires a User Event. This allows your main event loop to not have to have the shift register logic inside of it, making it easier to add/remove the handling for additional scales or other run-time-changeable properties. Yes, it is a polling loop that is continuously running, but in the vast majority of VIs intended for the user to actually see, it has no human-noticeable impact on the responsiveness of the UI.

Link to comment

Another variation that works for almost all similar situations is to have a separate loop that just polls every 100ms or so, comparing the last known value (in shift register) to the current value. If it detects a change in the value, then it fires a User Event. This allows your main event loop to not have to have the shift register logic inside of it, making it easier to add/remove the handling for additional scales or other run-time-changeable properties. Yes, it is a polling loop that is continuously running, but in the vast majority of VIs intended for the user to actually see, it has no human-noticeable impact on the responsiveness of the UI.

If someone has a real aversion to the polling method, it might be just as well to make a parallel event loop, registering for the same events you would in your main loop.

Link to comment

If someone has a real aversion to the polling method, it might be just as well to make a parallel event loop, registering for the same events you would in your main loop.

The problem is that in this case, there are no events that directly represent the action for which the programmer wants to register. Registering for the mouse and keyboard events is a hack that has to be done very precisely, and it gets really tricky when there are multiple controls/labels/etc that need to be monitored. The polling loop addresses these concerns.
Link to comment

Registering for the mouse and keyboard events is a hack that has to be done very precisely, and it gets really tricky when there are multiple controls/labels/etc that need to be monitored. The polling loop addresses these concerns.

Very true. Your suggestion makes better sense now. ;)

Has anyone written a framework to turn a polling VI into a User Event? I think it could be made generic enough to have some good use cases, though it would probably need to be class-based in order to use strict typing on the UEs. Could be fun to develop.

Link to comment

a simple way to throttle the polling loop is to use the "Wait for Front Panel Activity" function with a long timeout (500 msec)

How can I have never known about this function? Thank you!

ALso when you convert an event loop into a polling event loop you will find that no matter how big the delay is your event case will respond immediately

to your keypress or value change!

Possible Reason for not knowing this it is NI always say "don't use the timeout" as it defeats the purpose of events.. I don't agree with that statement entirely.

Having a timeout is a nice when you want to have a way to get control back when developing event handling code.

Once developed it can be removed easily.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.