# Visual Basic > Visual Basic 6 and Earlier >  [RESOLVED] Cairo Set Focus? Is it different than usual?

## -Corso->

https://www.dropbox.com/s/qpvxhkrzvm...creen.jpg?dl=0

Hi Cairo Squad, (Image above)
Just wondering what I'm missing here.
On the main screen, you press the letter 'q' and the big blue form(widget actually) appears. It's working well.
However, pressing 'q' again should close it. But, I first have to click the big blue form to activate it, then press 'q'.

But, no matter how much I try to 'SetFocus' (or other related things) to the blue form, I can't get it active and ready to respond to keystrokes from the get-go. It responds to mouse hovers immediately (over the close button, top right). 

So, my question, how on earth do we get this form reading keystrokes as soon as it appears?

Thanks!

----------


## Schmidt

> On the main screen, you press the letter 'q' - 
> and the big blue form(widget actually) appears. 
> It's working well.


So far, so good...
And you probably have used the KeyDown-Event on your Main-Form -
and set the Visible-State of your Widget to True.


```
'KeyDown-Event-Handler in fMain.frm
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  Select Case KeyCode
     Case vbKeyQ: fOverlay.PL.Widget.Visible = Not fOverlay.PL.Widget.Visible
  End Select
End Sub
```

But since you have an additional Form (the transparent Overlay-Form) - 
the KeyBoard-Focus might change to that (Widget-)Form - 
and now your fMain-KeyBoard-Handler above, doesn't react anymore.

We had this topic already in another discussion - where I've mentioned,
 that the easiest solution is "Event-Delegation" (from cfOverlay.cls-Form to fMain.frm Form).

For that, you have to make the above listed fMain-EventHandler Public first:


```
'KeyDown-Event-Handler in fMain.frm
Public Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  Select Case KeyCode
     Case vbKeyQ: fOverlay.PL.Widget.Visible = Not fOverlay.PL.Widget.Visible
  End Select
End Sub
```

Followed by an Event-Delegation Code-Snippet, which is placed in your cfOverlay-Form 
(I'm still referring to the "Planets-Demo", because you still do not post Code-examples).


```
'KeyDown-Event-Handler in cfOverlay.cls - the Host-Class of your transparent Widget-Form
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  fMain.Form_KeyDown KeyCode, Shift '<- delegate KeyPresses on the Overlay-Form, to the matching fMain-Form-Event
End Sub
```

HTH

Olaf

----------


## -Corso->

I actually had no idea we could make Form Subs Public, but now I do(!).  :Thumb: 
I might just send all the Invisible Overlay responses to a module in the future. Keeping neat. 
Ok, that works rather well. So the Invisible Overlay is the Master Driver regardless of the Widget.
So is the .SetFocus serves no use for widgets? It has no function other than to confuse us all?

As for uploading the master code, it's waaay too tricky now. This BEAST now pulls in from all over the place, many small and large images to construct itself. I don't want to put 'certain aspect pictures' online. I was hoping it was a small issue of me not doing something completely obvious for this one. At any rate, it's probably better if I 'adjust' and submit the Planets demo code bits for anything that that goes awry in the future. At least this way we've got a common baseline. 

Ok, back to the slog, I'm going to test vertical scroll bars with special spaced inventory graphics now. 

Mind you, this press 'q' for the character inventory sheet is super neat. So clean, smooth and quick. Can't wait to see how it fast it handles the inventory presentation.

Muchly Thanks Again Olaf!

----------

