Jump to content
TheCrimsonCrusader

Tabbing between input fields in a GUI

Recommended Posts

TheCrimsonCrusader

Greetings,

This hails from a GUI someone else created awhile ago (sorry, don't recall).  I largely gutted the code to make it quicker to read here.  There are two selections on the left side that update what is shown on the right side when they are clicked on and the first selection has two input fields. 

When I press the <TAB> key in the first input field, it highlights the text that is entered.  What I am wanting to do is having it TAB down to the next input field.  Any idea on how to do this?   Thanks in advance.

#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#region GLOBAL VARIABLES
Global $iW = 482, $iH = 300, $iT = 80, $iB = 52, $iLeftWidth = 150, $iGap = 10, $hMainGUI
#endregion GLOBAL VARIABLES

_MainGui()

Func _MainGui()
Local $nMsg, $aPos
Local $iLinks =3
Local $aLink[$iLinks], $aPanel[$iLinks]
$aLink[0] = $iLinks - 1
$aPanel[0] = $iLinks - 1
$hMainGUI = GUICreate("Test Title", $iW, $iH, -1, -1, BitOR($WS_DLGFRAME, $WS_EX_TOPMOST))


;add links to the left side
$aLink[1] = _AddNewLink("Selection 1")
$aLink[2] = _AddNewLink("Selection 2", -167)

;and the corresponding GUI's
$aPanel[1] = _AddNewPanel("Panel 1")
$aPanel[2] = _AddNewPanel("Panel 2")


;add some controls to the panels
_AddControlsToPanel($aPanel[1])
GUICtrlCreateLabel("Label1", 8, 38, 36, 17)
Local $hInput1a = GUICtrlCreateInput("", 56, 35, 121, 21)
Local $hInput1b = GUICtrlCreateInput("", 56, 65, 121, 21)
Local $hButton1 = GUICtrlCreateButton("Button1", 200, 33, 75, 25)

_AddControlsToPanel($aPanel[2])
GUICtrlCreateLabel("Label2", 8, 38, 36, 17)
Local $hInput2 = GUICtrlCreateInput("", 56, 35, 121, 21)
Local $hButton2 = GUICtrlCreateButton("Button2", 200, 33, 75, 25)


;set default to Panel1
GUISwitch($aPanel[1])
;show the main GUI
GUISetState(@SW_SHOW, $hMainGUI)

While 1
Sleep(10)
$nMsg = GUIGetMsg(1)
Switch $nMsg[1]
Case $hMainGUI
Switch $nMsg[0]

Case $aLink[1], $aLink[2]
For $i = 1 To $aLink[0]

If $nMsg[0] = $aLink[$i] Then
GUISetState(@SW_SHOW, $aPanel[$i])
Else
GUISetState(@SW_HIDE, $aPanel[$i])
EndIf
Next
EndSwitch

Case $aPanel[1]
Switch $nMsg[0]
Case $hButton1
MsgBox(32, "Test1", "You entered " & GUICtrlRead($hInput1a))
MsgBox(32, "Test1", "You entered " & GUICtrlRead($hInput1b))
EndSwitch

Case $aPanel[2]
Switch $nMsg[0]
Case $hButton2
MsgBox(32, "Test2", "You entered " & GUICtrlRead($hInput2))
EndSwitch

EndSwitch
WEnd
EndFunc ;==>_MainGui

Func _AddNewLink($sTxt, $iIcon = -44)
Local $hLink = GUICtrlCreateLabel($sTxt, 36, $iT + $iGap, $iLeftWidth - 46, 17)
;GUICtrlSetCursor(-1, 0)
$iGap += 22
Return $hLink
EndFunc ;==>_AddNewLink

Func _AddNewPanel($sTxt)
Local $gui = GUICreate("", $iW - $iLeftWidth + 2, $iH - $iT - $iB, $iLeftWidth + 2, $iT, $WS_CHILD + $WS_VISIBLE, -1, $hMainGUI)
GUICtrlCreateLabel($sTxt, 10, 10, $iW - $iLeftWidth - 20, 17, $SS_CENTERIMAGE)
Return $gui
EndFunc ;==>_AddNewPanel

Func _AddControlsToPanel($hPanel)
GUISwitch($hPanel)
EndFunc ;==>_AddControlsToPanel


 

Share this post


Link to post
Share on other sites
Bilgus

Its probably one of the default styles for the Input control doing it but just switch to edit controls with a style of 0 and it'll work how you want

Local $hInput1a = GUICtrlCreateEdit("", 56, 35, 121, 21, 0 )
Local $hInput1b = GUICtrlCreateEdit("", 56, 65, 121, 21, 0 )

 

Share this post


Link to post
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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.