From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems changing KeyFocus / FocusKeyBinding on a MouseDown event

Im trying to use the KeyFocus and FocusKeyBinding control properties to make buttons behave more like other windows apps.  The behavior I am looking for is to set focus on the button (the usual Tabbing indicator) as well as get a dark outline around the button when the user clicks in it.. ie. change that key's FocusKeyBinding property to "<Enter>".
 
Setting the KeyFocus in the MouseDown event worked as planned.  Setting the FocusKeyBinding has some issues though. 😞  It will put the dark outline around the button when you set it to "<Enter>" but fails to remove it if you change it again until the front panel redraws the button.
 
I tried to force a redraw by fiddling with DeferPanelUpdates, but that doesn't work either.  I attached a simple example demonstrating the problem...
 
I just need some way to force the button to redraw itself.. Maybe if I hide/unhide it? That's pretty silly though, no?
 
Argggg!
 
 
-John
0 Kudos
Message 1 of 6
(2,575 Views)
I don't see any problem in 7.1. The buttons in the attached VI lose the outline when the next button is clicked. Does this work in 8.2?

___________________
Try to take over the world!
0 Kudos
Message 2 of 6
(2,560 Views)

Nope. 😞

It does the same as my example.  Perhaps I failed to mention that Classic and Modern style buttons work properly? It's only the System style that won't remove the dark outline.

Like I said though, the outline does go away if you make the window refresh by moving it partially offscreen or minimizing it, etc.

The system style buttons work properly in 7.1 though?

0 Kudos
Message 3 of 6
(2,554 Views)

Ah, I see what you're talking about now and it does happen in 7.1 dialog (system) controls as well. Perhaps because I'm using the classic Windows look it's not as noticable, or maybe it's simply that I wasn't aware of it.


___________________
Try to take over the world!
0 Kudos
Message 4 of 6
(2,542 Views)
Aright,
 
I guess I was on the right track when I suggested hiding/unhiding the control.  By setting the Visibility of the previous control to false and then true it redraws.  More accurately, it redraws when DeferPanelUpdates is used.
 
I'm confused as to why Visibility = false/true makes DeferPanelUpdates redraw the control but won't redraw it if DeferPanelUpdates isn't used at all..
 
Anyhow, there are more details to consider in doing all this, for example if you press Tab after clicking a button, the outline on the last-clicked button goes away even though it's FocusKeyBinding is <Enter> @$!@#%!@$!#$.
 
I'm going to have to put this interface detail on hold for a while so I can get real work done.

Message Edited by jbutera on 01-28-2007 05:10 PM

0 Kudos
Message 5 of 6
(2,538 Views)

Hi John,

This was reported to R&D (# 45T4IEX6) for further investigation. Thanks for the feedback!

Regards,
Ching P.
DAQ and Academic Hardware R&D
National Instruments
0 Kudos
Message 6 of 6
(2,522 Views)