Sign in to follow this  
Followers 0
strate

Button Focus

6 posts in this topic

I have a gui with just two inputs and a button. I made the tab order so that the user can

enter data into the first input

hit enter

enter data into the second input

hit enter

this creates a focus on the button

user hits enter again to return to the first input then repeats.

What happens though is that after the first time thru the button is disabled and the user will have to click on it with the mouse. I need it so that the user can keep hitting enter. If after the first time thru, you activate a different window then return to the GUI it will accept the enter key stroke.

How can this be fixed? I've tried setting focus to it but that doesn't help.


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites



depends on where you put the $GUI_FOCUS..

also.... maybe you can use

GUICtrlSetStyle ($button, $BS_DEFPUSHBUTTON )

in the right places

( no code... no testing for you )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Yeah I'm trying to get useable code.


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <GUIConstants.au3>
#Include <GuiList.au3>

$Form1 = GUICreate("Labels", 682, 460, 228, 186)
$Group3 = GUICtrlCreateGroup("Identification Labels", 240, 88, 201, 153)
GUICtrlSetColor(-1, 0x0000FF)
$Label8 = GUICtrlCreateLabel("Quantity on Label:", 256, 112, 90, 16)
$IDQty = GUICtrlCreateInput("", 256, 128, 89, 21)
$Label9 = GUICtrlCreateLabel("Number of labels with this quantity:", 256, 160, 167, 16)
$IDQtyofLabels = GUICtrlCreateInput("", 256, 176, 89, 21)
$IDAdd = GUICtrlCreateButton("Add", 256, 208, 89, 20, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 464, 308, 201, 123)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $IDAdd
            Local $QtyPerLabel = GUICtrlRead($IDQty)
            Local $QtyofLabels = GUICtrlRead($IDQtyofLabels)
            
            If $QtyPerLabel = '' Or $QtyofLabels = '' Then ContinueLoop

            If $QtyofLabels > 1 Then
                _GUICtrlListAddItem($List1, $QtyofLabels & ' labels at a quantity of ' & $QtyPerLabel)
            Else
                _GUICtrlListAddItem($List1, $QtyofLabels & ' label at a quantity of ' & $QtyPerLabel)
            EndIf
            
            GUICtrlSetData($IDQty,'')
            GUICtrlSetData($IDQtyofLabels,'')
            GUICtrlSetState($IDQty,$GUI_FOCUS)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If StringInStr(ControlGetFocus($Form1),'Edit') Then
        HotKeySet('{ENTER}','_CatchEnterThenTab')
    Else
        HotKeySet('{ENTER}')
    EndIf
WEnd

Func _CatchEnterThenTab()
    Send('{TAB}')
EndFunc

EDIT:

I was wrong about the GUI_Focus it was to return it to the first input.

Edited by strate

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

maybe.....

#include <GUIConstants.au3>
#Include <GuiList.au3>

$Form1 = GUICreate("Labels", 682, 460, 228, 186)
$Group3 = GUICtrlCreateGroup("Identification Labels", 240, 88, 201, 153)
GUICtrlSetColor(-1, 0x0000FF)
$Label8 = GUICtrlCreateLabel("Quantity on Label:", 256, 112, 90, 16)
$IDQty = GUICtrlCreateInput("", 256, 128, 89, 21)
$Label9 = GUICtrlCreateLabel("Number of labels with this quantity:", 256, 160, 167, 16)
$IDQtyofLabels = GUICtrlCreateInput("", 256, 176, 89, 21)
$IDAdd = GUICtrlCreateButton("Add", 256, 208, 89, 20, $BS_DEFPUSHBUTTON)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 464, 308, 201, 123)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $IDAdd
            Local $QtyPerLabel = GUICtrlRead($IDQty)
            Local $QtyofLabels = GUICtrlRead($IDQtyofLabels)
            
            If $QtyPerLabel = '' Or $QtyofLabels = '' Then ContinueLoop

            If $QtyofLabels > 1 Then
                _GUICtrlListAddItem($List1, $QtyofLabels & ' labels at a quantity of ' & $QtyPerLabel)
            Else
                _GUICtrlListAddItem($List1, $QtyofLabels & ' label at a quantity of ' & $QtyPerLabel)
            EndIf
            
            GUICtrlSetData($IDQty,'')
            GUICtrlSetData($IDQtyofLabels,'')
            GUICtrlSetState($IDQty,$GUI_FOCUS)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#Include <GuiList.au3>
$form1 = GUICreate("Labels", 682, 460, 228, 186)
$group3 = GUICtrlCreateGroup("Identification Labels", 240, 88, 201, 153)
GUICtrlSetColor(-1, 0x0000FF)
$label8 = GUICtrlCreateLabel("Quantity on Label:", 256, 112, 90, 16)
$idqty = GUICtrlCreateInput("", 256, 128, 89, 21)
$label9 = GUICtrlCreateLabel("Number of labels with this quantity:", 256, 160, 167, 16)
$idqtyoflabels = GUICtrlCreateInput("", 256, 176, 89, 21)
$idadd = GUICtrlCreateButton("Add", 256, 208, 89, 20, $bs_defpushbutton)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$list1 = GUICtrlCreateList("", 464, 308, 201, 123)
GUISetState(@SW_SHOW)
While 1
    $nmsg = GUIGetMsg()
    Switch $nmsg
        Case $idadd
            Local $qtyperlabel = GUICtrlRead($idqty)
            Local $qtyoflabels = GUICtrlRead($idqtyoflabels)
            Local $complete = True
            If $qtyperlabel = '' And $complete Then
                $complete = False
                GUICtrlSetState($idqty, $gui_focus)
            EndIf
            If $qtyoflabels = '' And $complete Then
                $complete = False
                GUICtrlSetState($idqtyoflabels, $gui_focus)
            EndIf
            If $complete Then
                If $qtyoflabels > 1 Then
                    _GUICtrlListAddItem($list1, $qtyoflabels & ' labels at a quantity of ' & $qtyperlabel)
                Else
                    _GUICtrlListAddItem($list1, $qtyoflabels & ' label at a quantity of ' & $qtyperlabel)
                EndIf
                GUICtrlSetData($idqty, '')
                GUICtrlSetData($idqtyoflabels, '')
                GUICtrlSetState($idqty, $gui_focus)
            EndIf
        Case $gui_event_close
            Exit
    EndSwitch
WEnd

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
Sign in to follow this  
Followers 0