Jump to content

Tab key doesn't sequence through input controls of child GUI


Recommended Posts

Hi all,

I am a relatively new user of AutoIt for GUI creation and have found it extremely useful in the past for creating scripts. I am creating a GUI which uses a treeview to allow the user to select between multiple child GUIs and then enter data in a series of input controls. Selecting an item in the tree activates its corresponding child GUI. I want the user to be able to enter a set of data on a given child GUI that I will use to perform some actions.

The problem I am having is that the tab key does not sequence through the input controls on the child GUI. Pressing the tab key instead moves the focus back on the treeview. I am not sure if I need to use the forced style $WS_TABSTOP to turn it into a tab stop, but I have tried that without success. Maybe I don't have the syntax correct. I do know that when the GUI doesn't include child GUIs, the tab key does sequence through the input controls without issue.

In order to reproduce the undesired behavior in the example GUI code below, please select the "first choice" item in the treeview using the mouse. Then press the tab key to move the focus to the "first input" input box on the child GUI. Pressing the tab key again will then take the focus back to the treeview item! I would like for the tab key to instead allow the user to cycle through the remainder of the input boxes on this child GUI.

Any help would be greatly appreciated!

CODE
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <TreeViewConstants.au3>

#include <EditConstants.au3>

Main()

Func Main()

$Main = GUICreate("My AutoIt GUI", 540, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

; ******************* Tree Structure with choice of child GUIs ****************************

$maintree = GUICtrlCreateTreeView(10, 10, 160, 450,BitOr($GUI_SS_DEFAULT_TREEVIEW, $WS_TABSTOP))

$choice1 = GUICtrlCreateTreeViewItem("First choice", $maintree)

$choice2 = GUICtrlCreateTreeViewItem("Second choice", $maintree)

; Number of child GUIs

Global $Child

Dim $Child[3]

Dim $children

$children = 3

;Label and input field start position and length

$lbl_xstart = 180

$lbl_length = 200

$field_xstart = 380

; Show main GUI

GUISetState()

; *********************************** CHILD GUI #1 **********************************

$Child[0] = GUICreate("", 540, 500, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Main)

GUISetFont(9, 800, -1, "")

GuiCtrlCreateLabel("First screen", $lbl_xstart+45, 20, 400, 25)

GUISetFont(8.5, 400, -1, "")

; labels and user inputs

$lbl1 = GuiCtrlCreateLabel("First input", $lbl_xstart, 75, $lbl_length, 25)

$input1 = GuiCtrlCreateInput("10", $field_xstart, 75, 60, 20, $WS_TABSTOP)

$lbl2 = GuiCtrlCreateLabel("Second input", $lbl_xstart, 100, $lbl_length, 25)

$input2 = GuiCtrlCreateInput("0.1", $field_xstart, 100, 60, 20, $WS_TABSTOP)

$lbl3 = GuiCtrlCreateLabel("Third input", $lbl_xstart, 125, $lbl_length, 25)

$input3 = GuiCtrlCreateInput("0.025", $field_xstart, 125, 60, 20, $WS_TABSTOP)

$lbl4 = GuiCtrlCreateLabel("Fourth input", $lbl_xstart, 150, $lbl_length, 25)

$input4 = GuiCtrlCreateInput("15", $field_xstart, 150, 60, 20, BitOR($GUI_SS_DEFAULT_INPUT, $WS_TABSTOP))

; run button

$runbutton1 = GUICtrlCreateButton("Execute", 260, 425, 100, 25)

GUISetState(@SW_SHOW)

; ************************* CHILD GUI #2 *********************************

$Child[1] = GUICreate("", 540, 500, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Main)

GUISetFont(9, 800, -1, "")

GuiCtrlCreateLabel("Second screen", $lbl_xstart+25, 20, 400, 25)

GUISetFont(8.5, 400, -1, "")

; labels and user inputs

$lbl5 = GuiCtrlCreateLabel("Fifth input", $lbl_xstart, 75, $lbl_length, 25)

$input5 = GuiCtrlCreateInput("2.4", $field_xstart, 75, 60, 20)

$lbl6 = GuiCtrlCreateLabel("Sixth input", $lbl_xstart, 100, $lbl_length, 25)

$input6 = GuiCtrlCreateInput("5", $field_xstart, 100, 60, 20)

$lbl7 = GuiCtrlCreateLabel("Seventh input", $lbl_xstart, 125, $lbl_length, 25)

$input7 = GuiCtrlCreateInput("5", $field_xstart, 125, 60, 20)

$lbl8 = GuiCtrlCreateLabel("Eighth input", $lbl_xstart, 150, 120, 25)

$input8 = GuiCtrlCreateInput("1", $field_xstart, 150, 60, 20)

; run button

$runbutton2 = GUICtrlCreateButton("Execute", 260, 425, 100, 25)

GUISetState(@SW_HIDE)

While 1

$msg = GUIGetMsg()

Select

Case $msg = -3 Or $msg = -1

ExitLoop

Case $msg = $choice1

;Display only this child GUI

For $x = 0 To $children - 1

GUISetState(@SW_HIDE, $Child[$x])

Next

GUISetState(@SW_SHOW, $Child[0])

Case $msg = $choice2

;Display only this child GUI

For $x = 0 To $children - 1

GUISetState(@SW_HIDE, $Child[$x])

Next

GUISetState(@SW_SHOW, $Child[1])

EndSelect

WEnd

GUIDelete()

Exit

EndFunc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...