02-08-2018 09:28 AM
Hello, I am creating an interface through SubVIs inside a cluster with a title and I'm trying to reproduce a "window move" effect when the mouse is clicked and moves through the window title (a string inside my cluster). It works already pretty good but when the mouse moves too quickly the window can't follow the mouse and loses the position ("mouse leave" event).
Can you suggest me a more efficent way to do this?
I attach a simplified version of my VI with only one cluster that can move through my front panel.
I hope you can help me, thanks in advance
Dario
Solved! Go to Solution.
02-08-2018 10:06 AM
02-08-2018 11:52 AM
I tried doing something similar using an all event method but I found that it had similar limitations to what you are finding. I was moving the entire window though, not things inside the window. I ended up watching for the mouse button release in the timeout instead of hoping for the event (this requires remembering if the button is pressed). I used the Acquire Input Data vi to get mouse information. Perhaps there is a reliable way to do this with events but I couldn't get it to work as well as I would have liked. To not miss clicks and update the window or cluster smoothly, you obviously need the timeout event to run pretty often. Like 1ms or something. I think you can get away with 10ms but it just looks more choppy. Generally though, you want to limit your busy waiting since it eats up CPU cycles.
02-09-2018 01:22 AM - edited 02-09-2018 01:33 AM
Sorry, I attach a VI with your suggestions (shift registers, stop event). Unfortunately this does not solve my problem 😞
Using the "Register Mouse Event" in the timeout event is way too CPU heavy (most of the time the user does not want to move the window).
One solution that I tried was to brutally slow down the speed of the mouse when i detect the mouse click so that the mouse can't go out of the window (no "mouse leave" event) but I found this solution not really elegant (I had to call a windows DLL to change the mouse speed). I attach this version too
Do you have other ideas?
02-09-2018 08:54 AM
Okay I think your problem is a little different than mine was (since it was an issue when I lost the mousemove when it left the pane). I think this should be good for you.
02-09-2018 09:27 AM
Wow that's cool! I'm not familiar with the feedback node, I'll try to understand how it works and apply it to my code! Thanks a lot!
02-09-2018 09:42 AM
Honestly, I very rarely use it. I just wanted to quickly debug the events. I think the better practice is to bundle all of your wires into a cluster and use the feedback terminal at the while or for loop like you were doing. But since you didn't have a cluster set up, I was lazy and just used a feedback node.
02-09-2018 09:58 AM
The most important thing is probably that you don't lock the front panel for the mouse move event and set the event queue size to 1.
02-12-2018 01:16 AM - edited 02-12-2018 01:20 AM
Unfortunately what I uploaded was a "simplified example", but in my original application all the "windows move" events are controlled by a Dynamic Event, where I don't have the "Limit maximum instances of this event in the event queue".
In any case i find that the last version that you uploaded has the same issues that my version had (when the mouse moves to fast it loses grip on the window move event), but the previous version didn't
02-12-2018 02:57 AM
Anyway what did the trick for me was to use the event "Mouse Move" on the whole FrontPanel and not on the DeviceName of the cluster (WindowTitle) as shown in the example you posted above. In this way I always have the coordinates of my mouse while the mouse left button is pressed.