Jump to content

Input Box Cleared w/ Click


Recommended Posts

Hi, I was wondering if you could clear the text from the Input field with just a press of a button?

I know I would need to make an Input field like so...

$input = GUICtrlCreateInput ( "I want this cleared with button press!", x, x, x, x )

Then I would need the button... this is what I don't know how to setup to make it clear the text from the Input field.

Thanks :(

Link to comment
Share on other sites

I'm not sure if you mean that you want the the input to be clear when

pressing a keyboard-button, or a GUI-button, but this example shows

how to do both :

#include <GUIConstants.au3>

GUICreate("Test",200,70)
$cInput = GUICtrlCreateInput("Blahahahha ! Znjurb ?",10,10,180,20)
$cClear = GUICtrlCreateButton("Clear !",10,40,180,20)
GUISetState()

HotKeySet("{numlock}","_ClearInput")

While 1
    Sleep(10)
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
    If $msg = $cClear Then GUICtrlSetData($cInput,"")
WEnd

Func _ClearInput()
    GUICtrlSetData($cInput,"")
EndFunc

Just press NumLock to clear the input-control, or press the "Clear"-button..

Link to comment
Share on other sites

Heh, no problem.

Just a little comment on your code.. instead of doing :

Case $msg = $cleartextbutton
    If $msg = $cleartextbutton Then
      GUICtrlSetData($input,"")
  EndIf

you could use :

Select
Case $msg = $cleartextbutton
    GUICtrlSetData($input,"")

With your script I think you really upset the Select, because

if he's saying that that's the case, then he's very often right.

You don't have to ask him once more :(

Damn, my eyes are screaming for new contact-lenses :(

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