vaimaro Posted March 24, 2007 Report Share Posted March 24, 2007 Hello, I want to ask is it corect to use numeric controls with "value change" detection in event structure? My task is is to make a program which goes to the case where hardware configuration paramters are after user changes values of numeric controls. For example, user changes Amplitude or Frequency (using dial) event structure detects this activity and chooses "ReConfigure" case, where new parameters to hardware are sent. The problem is that instaed of one event generated after dial realese, I get many events (2...4) thus "ReConfigure" case is used 2..4 times in the sequence. I have never seen examples where numeric controls are used to generate events. Thus maybe it is not correct usage of event structure with numeric controls, only buttons should be used? Thank you, Vaidas Quote Link to comment
lraynal Posted March 24, 2007 Report Share Posted March 24, 2007 It's pretty hard to answer you, as you pointed out the problem on the "numeric - value change - event structure". An event is generated everytime you modify the numeric... so as many event as modification... Depending on the king of program you are doing, you can use or not use this kind of event... personnaly, I use it sometimes, but not always because of this particular problem you pointed out! What you can do, for example, is a hidden button which appear on the "value change" event, and the action you want (ReConfigure) will be triggered only on this button (which will disappear until the next modification of the numeric...). You can think of other possibilities, like a delai between the first modification and the action... Good luck. laurent Quote Link to comment
Ton Plomp Posted March 24, 2007 Report Share Posted March 24, 2007 A value change event on a numeric is a valid use case. But a dial (or slide) is a different thing, what you most likely want is a to check if the mouse button is up. A simple mouse up-event wouldn't work because you can change the value while the mouse-pointer is outside the control (test this: mouse down on the control, move mouse out of control, and you can change the dial value, but you won't get a mouse-up event). So you better get a 'value change' event, and check with the mouse status vi for a mouse-up state (eg. don't act if the mouse is down) Ton Quote Link to comment
Dave Graybeal Posted March 24, 2007 Report Share Posted March 24, 2007 It sounds like he might just be trying to use a numeric control with the increment and decrement. Each click of the Increment(or Decrement) will trigger an event value change. So if your numeric Control is set to 1 and you want to get to 4 you click the increment button 3 times. This will trigger 3 value change events for the control. Although I believe I see what he's trying to do, I'm not sure I have a good answer to solve this problem. Maybe someone else will have a recomendation for this scenario. Dave Graybeal Quote Link to comment
Mark Balla Posted March 25, 2007 Report Share Posted March 25, 2007 QUOTE(vaimaro @ Mar 23 2007, 02:49 AM) Hello,I want to ask is it corect to use numeric controls with "value change" detection in event structure? My task is is to make a program which goes to the case where hardware configuration paramters are after user changes values of numeric controls. For example, user changes Amplitude or Frequency (using dial) event structure detects this activity and chooses "ReConfigure" case, where new parameters to hardware are sent. The problem is that instaed of one event generated after dial realese, I get many events (2...4) thus "ReConfigure" case is used 2..4 times in the sequence. I have never seen examples where numeric controls are used to generate events. Thus maybe it is not correct usage of event structure with numeric controls, only buttons should be used? Thank you, Vaidas Here is a method I use to solve this type of problem. On an Value change event it sets a flage and starts a delay timmer. It waits until the slider control has not change for a specified amount of time. I have tried to use the mouse up event but found it would not be detected if the mouse was moved off of the front Panel. hope this helps. http://forums.lavag.org/index.php?act=attach&type=post&id=5277''>http://forums.lavag.org/index.php?act=attach&type=post&id=5277'>http://forums.lavag.org/index.php?act=attach&type=post&id=5277 Quote Link to comment
Aristos Queue Posted March 25, 2007 Report Share Posted March 25, 2007 I tried for a few hours to come up with something... didn't do so good. First thought: Let's use Mouse Up and Mouse Down to ignore the Value Changed event. So when we get Mouse Down, we'll set a boolean that says "ah, we've started gathering data." Then, on a Mouse Up, if the boolean was set, we should actually acknowledge a Value Changed event. That doesn't work because you don't get a Mouse Up event if the user releases the mouse while not over the control, even though the value keeps changing while the user holds down the mouse button, even when not over the control. So, I thought I'd get all clever and do this: on Mouse Enter, enable the knob. On Mouse Leave, disable the knob. Silly me, I thought this might stop us from changing the value of the control once the user left the region of the knob. I could thus register a Value Changed on Mouse Leave and on Mouse Up. Nope. Value happily keeps changing if you programmatically disable the knob while the mouse button is already down. Ok. So then I used Mouse Enter and Mouse Leave to control the value... On a Mouse Leave, I'd set a boolean to false. While that boolean is false, if there were any Value Changed events, I'd just set the value right back to the old value. That worked, except for the horrible redraw problem -- lots of flickering from old value to new value. So I tried creating a second knob stacked exactly on top of the first knob. That second knob would be hidden any time the mouse was not over the knob pair. On Mouse Leave, I woudl show the second knob, with its value set to whatever the value of the first knob was at the moment the mouse left. That was great at getting rid of the flicker -- but there was still the damn value tip strip. There's no way to hide, supress or disable that tipstrip. ARGH. Anyway, my final VI is attached to this post. Anyone want to try carrying this further? By the way... what we really need it seems is something akin to what is on a String control. A string has the option of "Update value while typing." Normally this is turned off, but you can turn it on if you really want a Value Changed on each keystroke. It seems like we'd like on knobs/sliders to have "Update value while dragging" --- and have it also default to off. (Though it would have to default to On for existing contols to provide the same behavior in existing programs). Quote Link to comment
Yair Posted March 25, 2007 Report Share Posted March 25, 2007 QUOTE(Aristos Queue @ Mar 24 2007, 08:30 AM) By the way... what we really need it seems is something akin to what is on a String control. A string has the option of "Update value while typing." Normally this is turned off, but you can turn it on if you really want a Value Changed on each keystroke. It seems like we'd like on knobs/sliders to have "Update value while dragging" --- and have it also default to off. (Though it would have to default to On for existing contols to provide the same behavior in existing programs). We also need this for events like mouse move. It would be nice if we could define something like "Only fire the event after moving x pixels or after staying still for y msec". BTW, if I understand your description correctly, this won't work when using the keyboard. :headbang: There is actually a surprisingly simple way to handle this - you just need to compare the value of the control to the value coming out of the NewVal terminal. If they're not equal, don't run your code. It's as simple as that, since the value of the terminal will usually be updated with the latest value by the time the event code runs. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.