LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Knob control randomly loses input from the mouse

Hello, I have been trying to run the code by @Altenback I found here inside of my main program. I run this file as a subvi, with while loop in the subvi being replaced by my main loop. When I run this subvi and nothing else inside of while loop, everything works fine (first part of the video), but then I put this subvi into my actual main program, it sometimes loses mouse input. When I press on the knob again, it regains input from the mouse, to then randomly lose it again. 

How should I go about troubleshooting it? I understand that something in my main loop is slowing it down... I think I have about ~100 ms of delay in my main loop. I see how it makes my knob movement a little bit more choppy, but I don't see how it register mouse button release.

Thanks

 

https://forums.ni.com/ni/attachments/ni/170/81151/1/TrimKnob.vi

 

0 Kudos
Message 1 of 5
(321 Views)

All that has to happen is the control loses focus for a split second and that is that.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 5
(287 Views)

I don't think that it loses focus, I've tried setting KeyFocus property to True before the event structure so that the control is always in focus, but it didn't resolve the problem, the subvi must be somehow registering mouse drag end event. I hope there's a simple solution to this, I don't want to write a custom event structure that detects mouse drag, drop, location change, etc.   

 

Edit: When I set execution of this subvi to be user interface and highest priority, this did not solve the problem. However, when I compiled everything as a executable, this resolved the problem. 

0 Kudos
Message 3 of 5
(242 Views)

@John32d wrote:

Hello, I have been trying to run the code by @Altenback I found here inside of my main program.

First of all, thanks for mentioning my name, but please spell it correctly. Much more important would be a link to the original discussion. 😄

 


@John32d wrote:

 

How should I go about troubleshooting it? I understand that something in my main loop is slowing it down... I think I have about ~100 ms of delay in my main loop. I see how it makes my knob movement a little bit more choppy, but I don't see how it register mouse button release.


A knob is an analog style control and can fill the event queue very fast with stale data. You need to limit the event queue to 1 and not lock the panel. (This option was not available back then! read more about it in this idea .).

 

altenbach_0-1708710442877.png

 

 

I also don't understand why you have a delay in a toplevel loop if it contains an event structure. Is this just a wait or a real delay because of complicated recalculations? Can you show us the rest of the code?

 

(I very strongly advise not to mess with priorities and threads as mentioned. It will make things worse! Also repeatedly setting key focus is not a good idea. You are just forcing yet another tread switch! If it "works" in the executable, that's no guarantee that it is really fixed.) 

 

 

0 Kudos
Message 4 of 5
(222 Views)

Thank you, sir for your time. 

 

I've made the suggested changes and though the knob runs much smoother, it doesn't resolve the problem. I ended up setting priority to normal and proffered system to user input, without setting focus programmatically, this is the only combination that doesn't cause this problem in the executable (when ran from LabView, I still occurs).

 

The main loop has delays (stall data flow) to keep TCP Read from immediately executing TCP Write, I don't read the right data from the device then. I thought that TCP buffer of the device should take care of it, but it doesn't. 

 

I appreciate the help. 

0 Kudos
Message 5 of 5
(200 Views)