Home All Groups Group Topic Archive Search About

detect tab keypress on checkbox - how?

Author
19 Oct 2005 8:10 AM
Marshal Anderson
Got a form with sstab control - several tabs. Separate from the tabs
is a cancel and a save button. What I want to happen is when the user
reaches the end of all the objects on a given tab page using teh tab
key, the focus goes to cancel button, the save button, then back to
the first control on tab (word 97 options does this for instance)

To do this I need to know when the tab key is pressed while the last
object on the tab has the focus so I can set the focus to the Cancel
button. BUT, VB6 doesn't seem to trap the keydown or keypress events
for checkboxes (the most frequent last object), unless it's the space
bar. I don;t want to use lostfocus because this creates very strange
behaviour for mouse users - they click another object and the focus
goes to the cancel button.

Only solution currently in my head is to send focus from last object
to a lable or something using tab order then trapping that focus and
redirecting it - but that's a bit heath-robinson.

Any suggestions? Am I missing somethinghere?

Marshal

Author
19 Oct 2005 8:39 AM
Jan Hyde
newsp***@getridofthismarshal.co.uk (Marshal Anderson)'s wild
thoughts were released on Wed, 19 Oct 2005 08:10:19 GMT
bearing the following fruit:

>Got a form with sstab control - several tabs. Separate from the tabs
>is a cancel and a save button. What I want to happen is when the user
>reaches the end of all the objects on a given tab page using teh tab
>key, the focus goes to cancel button, the save button, then back to
>the first control on tab (word 97 options does this for instance)
>
>To do this I need to know when the tab key is pressed while the last
>object on the tab has the focus so I can set the focus to the Cancel
>button.

No you don't, what you need to do is disable any controls on
the other tabs. Since you've put a frame on each tab to hold
the controls (if not then do it now) then it's simply a case
of disabling the other frames. Luckily an event fires when
the user changes tab which makes enabling and disabling the
relevant frames a piece of cake.

Then you will be able to tab along the form as you indicated
(providing you've set the tabidexes correctly).

J



Show quoteHide quote
>BUT, VB6 doesn't seem to trap the keydown or keypress events
>for checkboxes (the most frequent last object), unless it's the space
>bar. I don;t want to use lostfocus because this creates very strange
>behaviour for mouse users - they click another object and the focus
>goes to the cancel button.
>
>Only solution currently in my head is to send focus from last object
>to a lable or something using tab order then trapping that focus and
>redirecting it - but that's a bit heath-robinson.
>
>Any suggestions? Am I missing somethinghere?
>
>Marshal


Jan Hyde (VB MVP)

--
The first scientists who studied fog were mistified.  (Mike Bull)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
19 Oct 2005 12:07 PM
Marshal Anderson
On Wed, 19 Oct 2005 09:39:28 +0100, Jan Hyde
<StellaDrin***@REMOVE.ME.uboot.com> wrote:


>
>No you don't, what you need to do is disable any controls on
Top hole :o)

Marshal

Show quoteHide quote
>the other tabs. Since you've put a frame on each tab to hold
>the controls (if not then do it now) then it's simply a case
>of disabling the other frames. Luckily an event fires when
>the user changes tab which makes enabling and disabling the
>relevant frames a piece of cake.
>
>Then you will be able to tab along the form as you indicated
>(providing you've set the tabidexes correctly).
>
>J