Jump to content

Is there an OnKeyPress event in the Input control?


Recommended Posts

Is there an OnKeyPress event in the Input GUI control? For example, need to create GUI form with 1 Input and 2 labels. And if any keyboard button was pressed in Input1 (or if the text in Input1 changed), then change text in label1, with current text from Input1. If the text in Input1 is not = nil/null or empty  and 'Enter' keyboard button was pressed, then change text in the label2, with current text from Input1.

Saw this OnKeyPress topic , but need a simpler example.

Edited by Razi
Link to comment
Share on other sites

15 hours ago, Razi said:

but need a simpler example.

I thing this is a start  :)

#include <GUIConstantsEx.au3>

Local $Form1 = GUICreate("Form1", 300, 150)
Local $Label1 = GUICtrlCreateLabel("Tip new txt and hit enter", 10, 10, 280, 21)
Local $Input1 = GUICtrlCreateInput("Tip new txt and hit enter", 10, 25, 280, 21)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Input1
            Local $NewTxt = GUICtrlRead($Input1)
            If StringLen($NewTxt) > 0 Then
                GUICtrlSetData($Label1, $NewTxt)
                ConsoleWrite("New txt = " & $NewTxt & @CRLF)
            Else
                ConsoleWrite("! New txt must be somthing" & @CRLF)
            EndIf

    EndSwitch
WEnd

 

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