Results 1 to 11 of 11

Thread: Is this a bug or by design?

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Is this a bug or by design?

    Attached is a simplified form that works similar to a project I am working on... you will notice you can tab through each field and then click the button.. which clears the form and sets focus back to the first control.. but then when you tab through.. it skips over the option buttons and goes from the first textbox to the second... is there a way around this??? When the form clears I need the tab order to stay intact and not skip over them...

    I know I can look for a tab key in the control before the options.. but it doesn't seem right for it to behave this way

    if both options are NOT cleared.. then the one that is true will get focus.. but if both are false they dont.. but on the first pass though they are both false and still get focus...
    Attached Files Attached Files

  2. #2
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843
    Huh.

    For some reason it does not let you tab to an unselected option group.

    Set one of the option group to a default value and it will work okay.

    I'm guessing is a side-effect of design, since you can't be on an unselected option control, when you tab on it, or cursor to it, it selects, not just highlight. Know what I mean?
    Merry Christmas

  3. #3
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Looks like a bug to me ...

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by JPicasso
    Huh.

    For some reason it does not let you tab to an unselected option group.

    Set one of the option group to a default value and it will work okay.

    I'm guessing is a side-effect of design, since you can't be on an unselected option control, when you tab on it, or cursor to it, it selects, not just highlight. Know what I mean?
    but did you notice that when both are unselected when you first run the app.. it works how it should... its only after you clear the options via code that it skips them...

    and i cant set one as default because this is how the specs are set up

  5. #5
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Originally posted by kleinma
    but did you notice that when both are unselected when you first run the app.. it works how it should... its only after you clear the options via code that it skips them...

    and i cant set one as default because this is how the specs are set up
    You can programmatically set the focus though. Check on the text boxe's lostfocus if the focus is changed using tab ... if it is set the focus to one of two options.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I don't know if it's a bug or not but this will fix it.

    VB Code:
    1. Dim i As Integer
    2.     Text1.Text = ""
    3.     Text2.Text = ""
    4.     For i = 0 To 1
    5.         Option1(i).Value = False
    6.         [b]Option1(i).TabStop = True[/b]
    7.     Next
    8.     Text1.SetFocus

  7. #7

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by techyspecy
    You can programmatically set the focus though. Check on the text boxe's lostfocus if the focus is changed using tab ... if it is set the focus to one of two options.
    yeah i know.. just seems like a shady work around for it... but it would probably be on the keypress of the previous control.. because the lostfocus wont give me a keycode value

  8. #8
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Originally posted by kleinma
    yeah i know.. just seems like a shady work around for it... but it would probably be on the keypress of the previous control.. because the lostfocus wont give me a keycode value
    What do you need keycode value for ??

    you could use this ..

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    4. Private Const VK_TAB = &H9
    5.  
    6. Private Sub Text2_LostFocus()
    7.     If GetTabState Then MsgBox "You just tabbed out of Text2"
    8. End Sub
    9.  
    10. Private Sub Text1_LostFocus()
    11.     If GetTabState Then MsgBox "You just tabbed out of Text1"
    12. End Sub
    13.  
    14. Private Function GetTabState() As Boolean
    15.     GetTabState = False
    16.     If GetKeyState(VK_TAB) And -256 Then
    17.         GetTabState = True
    18.     End If
    19. End Function

  9. #9

  10. #10

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by MartinLiss
    kleinma: The problem is that for some reason the TabStop property gets set to False after tabbing through it the first time. My code above fixes that and it works for me. Did it fix your problem?
    yeah it did.. thanks.. i didn't even see your post at first... i was going to look at that.. but i didn't see why changing the value property would change any other property...

    i would say its a bug!

  11. #11
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843
    It takes the tab stop property off of option boxes that are not selected.
    setting the option value to false, or selecting a different option in a group will set the tab stop prop to false.

    I think it's so that when you get around to tabbing back to the group of options,
    it will highlight the selected option, since being on an option will select it.

    kinda good, kinda annoying.
    Merry Christmas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width