Sign in to follow this  
Followers 0
gottygolly

Input and button setting data to list.

3 posts in this topic

I have a script that has a button and a input, I want the user to be able to press enter on the input and send data to a list (This works fine). The problem im having though is if the user types in the input "Hi" or any text and then hits the button it will add "Hi" to the list twice even if the user didn't press enter.

Any thoughts on how to fix this?

[There is probably an answer to this some where but I didn't know how to search for it.]

#include<guiconstants.au3>
$gui = GUICreate("",200,200,-1,-1)
Opt("GUIOnEventMode",1)
GUISetOnEvent(-3,"_Exit")
Global $input = GUICtrlCreateInput("",5,5,190,20,$ss_center)
GUICtrlSetOnEvent($input,"_Input")
$button = GUICtrlCreateButton("Button",5,30,100,25)
GUICtrlSetOnEvent($button,"_Input")
$list = GUICtrlCreateList("List",5,60,190,100)
GUISetState()
While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc

Func _Input()
    ;GUICtrlSetState($button,$GUI_FOCUS) ;Tried this but still added it twice.
    $Read = GUICtrlRead($input)
    GUICtrlSetData($list,$read&"|")
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Add style to your bottom

$button = GUICtrlCreateButton

( "Button" , 5 , 30 , 100 , 25, $BS_DEFPUSHBUTTON )

No need of

GUICtrlSetOnEvent ($input,"_Input")

Edited by sdfaheemuddin

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