MartinPeeker Posted December 2, 2013 Report Share Posted December 2, 2013 Crosspost from here, didn't get momentum there though. I'm trying to prevent accidental stealing of focus from a string control by discarding the Mouse down? filter event. It turns out however that mouse down on any control or indicator that can take any input, such as strings, numerics, paths etc takes focus away from the string control. Is there a use case for this that I can't see or is it a bug? FocusLab.vi Quote Link to comment
hooovahh Posted December 2, 2013 Report Share Posted December 2, 2013 I think it is a bug but NI may disagree. The only other thing I have to add is I wanted to see what control LabVIEW though was in focus and found a private method called "Text Focus" using the front panel reference. By the way I think this method should be public if NI is listening. In either case when I went to read the control that has focus it returns a reference with a value of 0 once you enter the Mouse Down? event. So this means that even before the event structure has a chance to discard the mouse change it will already have lost the focus so by the time LabVIEW discards the mouse down it will be too late. I also tried disabling the control and it still would steal focus. FocusLab hooovahh.vi Quote Link to comment
MartinPeeker Posted December 3, 2013 Author Report Share Posted December 3, 2013 Thanks for that hooovahh. To make things a bit more puzzling, I thought I had a workaround by setting the key focus back where I wanted it in the 'Mouse down?' event. Works well in my little example, focus stays on my string control if I type and click the indicator at the same time. It doesn't work in my application though, focus is stolen and the typing jumps to the start of the string control. In all honesty I should mention that the actual application is somewhat larger and has three event structures in it, although no other event structure handles any mouse events nor any filter events. I tried adding a wait before setting focus back at the control thinking that would kill my workaround as in my application, but it turns out that it works even with a lengthy wait in the 'Mouse down?' event. FocusLabWithWait.vi Quote Link to comment
MartinPeeker Posted December 3, 2013 Author Report Share Posted December 3, 2013 Tried disabling the other event structures - didn't help.... 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.