Jump to content

Need help with Clear input box on click


Recommended Posts

Hi, I have 2 input box on a gui and i wanted to be able to click on a specific one to clear out what ever txt in it. Can someone please help

#include <GuiConstants.au3>

$gui = GUICreate("test", 300, 100)

$input1 = GUICtrlCreateInput("input test", 10, 10, 250, 30)

$input2 = GUICtrlCreateInput("another input test", 10, 40, 250, 30)

GUISetState()

While 1

WEnd
Edited by astrax
Link to comment
Share on other sites

  • Moderators

astrax,

I hope this does what you want:

#include <GUIConstantsEx.au3>

_Clear_Input()

Func _Clear_Input()

    $hGUI = GUICreate("Test", 500, 500)
    
    $hInput_1 = GUICtrlCreateInput("Input_1 ", 10, 10, 200, 20)
    $hInput_2 = GUICtrlCreateInput("Input_2 ", 10, 80, 200, 20)
    
    GUISetState()

    While 1
        
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
        
        $aInfo = GUIGetCursorInfo($hGUI)
        If $aInfo[2] Then
            If $aInfo[4] = $hInput_1 Then GUICtrlSetData($hInput_1, "")
            If $aInfo[4] = $hInput_2 Then GUICtrlSetData($hInput_2, "")
        EndIf
        
    WEnd

EndFunc;==>_Clear_Input

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

This is great!!!! Thank you so much.

astrax,

I hope this does what you want:

#include <GUIConstantsEx.au3>

_Clear_Input()

Func _Clear_Input()

    $hGUI = GUICreate("Test", 500, 500)
    
    $hInput_1 = GUICtrlCreateInput("Input_1 ", 10, 10, 200, 20)
    $hInput_2 = GUICtrlCreateInput("Input_2 ", 10, 80, 200, 20)
    
    GUISetState()

    While 1
        
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
        
        $aInfo = GUIGetCursorInfo($hGUI)
        If $aInfo[2] Then
            If $aInfo[4] = $hInput_1 Then GUICtrlSetData($hInput_1, "")
            If $aInfo[4] = $hInput_2 Then GUICtrlSetData($hInput_2, "")
        EndIf
        
    WEnd

EndFunc;==>_Clear_Input

M23

Link to comment
Share on other sites

  • 8 years later...
  • Moderators

antonioj84,

And how is that a better solution? If the user clicks on $hInput_2 how will your code clear it? The idea is to clear the input in which the user clicks - not just a specific one.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Case $Start
;******************************************************************Error Checking start****************************************
             
            If GUICtrlRead($Input1) = "" Then
                MsgBox(0, "WarNing", "StoreNumber is blank", 3)
            ElseIf GUICtrlRead($Radio1) = $GUI_UNCHECKED And GUICtrlRead($Radio2) = $GUI_UNCHECKED Then
                MsgBox(0, "WarNing", "must select Tablet or Fixed POS", 3)
            ElseIf GUICtrlRead($hCombo) = "" Then
                MsgBox(0, "WarNing", "must Select register number", 3)

            ElseIf  StringLeft($checknum, 1) <> 9  And BitAND(GUICtrlRead($idCheckbox), $GUI_CHECKED) And GUICtrlRead($Radio2) = $GUI_UNCHECKED    Then ; check for training RIAB in position 2 check value  store number if  not start with 9
            MsgBox(0, "error", "Training RIAB MUST START WITH 9")
            GUICtrlSetState($Input1, $GUI_FOCUS)
            GUICtrlSetData($Input1, "") ;Reset input


            ElseIf  StringLeft($checknum, 1) = 9  And BitAND(GUICtrlRead($idCheckbox), $GUI_CHECKED) or BitAND(GUICtrlRead($idCheckbox), $GUI_UNCHECKED) And GUICtrlRead($Radio2) = $GUI_CHECKED    Then
            MsgBox(0,"Warning"," tablet store number don't start with a 9")
            GUICtrlSetState($Input1, $GUI_FOCUS)
            GUICtrlSetData($Input1, "") ;Reset input
                

            ElseIf  StringLeft($checknum, 1) = 9  And BitAND(GUICtrlRead($idCheckbox), $GUI_UNCHECKED) And GUICtrlRead($Radio1) = $GUI_CHECKED    Then
            MsgBox(0,"Warning"," Live store number don't start with a 9")
            GUICtrlSetState($Input1, $GUI_FOCUS)
            GUICtrlSetData($Input1, "") ;Reset input

here is a little snippet from my code that work for me, other option  ;~ GUICtrlSetState($Input3, $GUI_ENABLE) , ;~ GUICtrlSetState($Input3, $GUI_DISABLE)

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...