Jump to content

What happens to my key focus when I interact with a scrollbar?


mje

Recommended Posts

So something weird is happening I can't quite explain. I have a VI with a multicolumn listbox (MCLB) that I have implemented virtually-- that is it can contain a prohibitive amount of data so I just maintain the list internally and only display the rows that are visible based on page settings of an adjacent scrollbar (SB):

 

post-11742-0-21364400-1397222365_thumb.p

 

The SB you see next to the MCLB called out in the image is not the one built in to the control, rather since I'm virtualizing the MCLB, the SB is a distinct control I maintain, set properties for, and respond to value change events by re-rendering the subset of data in the MCLB. This actually works very well, I've done so in many UIs over the years.

 

The problem I'm having with this implementation is I don't know what happens to my key focus when the SB is used. Unlike my previous implementations, I have event handlers to navigate the MCLB when things like the arrow or page keys are pressed, but if the user interacts with the SB those handlers are lost because the key focus seems to just vanish into a void. After interacting with the SB I can see the key events by handling them at the VI level, but the FocusObj comes back with a NULL valued refnum (specifically a zero/NULL value, not the NotARefnum value) so I can't query it for any properties to determine if the VS has the focus. If I move the event handler to the key events arising from the SB itself, they never fire as the SB seems incapable of taking the key focus.

 

I've tried setting the focus back to the MCLB from the value change event of the SB, but that doesn't seem to work either. I'd rather not lose my ability to navigate the MCLB after the VS is interacted with.

 

I don't really have any code to show-- I mean if the event data is returning NULL refnums there's really  nothing I can do with the event. Has anyone dealt with key focus on a scrollbar before?

Link to comment
I've tried setting the focus back to the MCLB from the value change event of the SB, but that doesn't seem to work either.

 

It seems to work just fine here with a simple example (Win 7, LV 2011). Maybe you should try to find out what the difference is (subpanels?).

 

Regardless, if you have just the single MCLB, you could just appropriate the navigation buttons and use them on it in the panel's Key Down event regardless of whether or not it actually has focus (either by writing the code to control the TopLeft cell or by having them set the focus to the control, which should probably also get it to work). Another alternative might be to make it into an XControl, which might be useful for you if you have this construct in multiple programs (or maybe it's already an XControl and that's the difference?).

Link to comment

Thanks for the idea Shaun, but I'm not entirely sure what you had in mind with that link.

 

Thanks for checking Yair. I threw together a quick demo to show the problem, attached as LV 2013. It's a little dirty because I wanted to throw everything into a single VI but should serve as an example.

 

MCLB+SB.vi

 

The problem seems to rise entirely because my MCLB is an indicator-- apparently as an indicator LabVIEW is incapable of setting the key focus? This seems like an odd restriction considering if I click on it at run time it clearly does achieve key focus. Is this desired behavior? It would seem like a bug to me.

 

I'd rather not make the MCLB a control, it would bring along a host of undesired behaviors, such as the cell focus box that can't be cleared and complicates key navigation since the control is by design not aware of any elements outside of what it displays.

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.