Jump to content

Mouse down filter event - focus


Recommended Posts

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

Link to comment

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

Link to comment

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

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.