PartyPooper Posted November 9, 2005 Posted November 9, 2005 I'm obviously missing something really simple here, but I have a combobox with a dropdown list that I can't seem to workout how to update it when I type in a manual answer (instead of selecting from the dropdown). I'm using the GUIOnEventMode and the combobox updates OK when I select items from its dropdown list (because I'm using GUICtrlSetOnEvent($var,"function") to intercept a change), however, if I type something in manually nothing happens because I'm unsure how to enter the input. Do I use the Enter key or do I have to create a button next to the combobox to "set" the manual entry?
poisonkiller Posted November 9, 2005 Posted November 9, 2005 Try: GUICtrlSetData($combo, GUICtrlRead($combo))
PartyPooper Posted November 9, 2005 Author Posted November 9, 2005 Yeah, thats what I thought but it's still not working. This is what I'm using: $Tyre = GUICtrlCreateCombo ( "Text",160, 40, 150) GUICtrlSetData($Tyre,"Brand1|Brand2|Brand3","Brand1") GUICtrlSetOnEvent($Tyre,"OnTyre") Func OnTyre() GUICtrlSetData($Tyre, GUICtrlRead($Tyre)) $Circumference = GUICtrlRead($Tyre) If GUICtrlRead ($Tyre) = "Brand1" OR GUICtrlRead ($Tyre) = "Brand2" Then $Circumference = 1.813 ElseIf GUICtrlRead ($Tyre) = "Brand3" Then $Circumference = 1.816 EndIf EndFunc The problem is when I manually enter Brand4 into the combobox, unless I create a "Set value" button next to the combobox that calls the OnTyre function, any manually entered value is not passed to other functions. I had thought pressing the enter key after placing a value into the combobox would trigger the OnEvent mode but it doesn't.
Moderators SmOke_N Posted November 9, 2005 Moderators Posted November 9, 2005 I have it entering... note the 2 msgbox debugs... #include <guiconstants.au3> Opt("GUIOnEventMode", 1) GUICreate("", 400, 200) $Tyre = GUICtrlCreateCombo ( "Text",160, 40, 150) GUICtrlSetData($Tyre,"Brand1|Brand2|Brand3","Brand1") GUICtrlSetOnEvent($Tyre,"OnTyre") GUISetState() While 1 Sleep(100) WEnd Func OnTyre() MsgBox(0, '', 'debug') GUICtrlSetData($Tyre, GUICtrlRead($Tyre)) $Circumference = GUICtrlRead($Tyre) MsgBox(0, "debug", $Circumference) If GUICtrlRead ($Tyre) = "Brand1" OR GUICtrlRead ($Tyre) = "Brand2" Then $Circumference = 1.813 ElseIf GUICtrlRead ($Tyre) = "Brand3" Then $Circumference = 1.816 EndIf EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
PartyPooper Posted November 9, 2005 Author Posted November 9, 2005 I still have the same problem. Click on Text, Brand1, Brand2 or Brand3 and it enters OK. Type in Brand4 and nothing happens.
Moderators SmOke_N Posted November 9, 2005 Moderators Posted November 9, 2005 I totally misread what you wrote then!!, I'm sorry. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
PartyPooper Posted November 9, 2005 Author Posted November 9, 2005 I totally misread what you wrote then!!, I'm sorry.Nevermind, I don't know what I was thinking - musta spent too long at the computer. In hindsight, I will have to put a "Save Settings" button on the GUI anyway so any manually entered values will be saved then. Thanks for your replies anyway - they helped me see the error in my logic
Moderators SmOke_N Posted November 10, 2005 Moderators Posted November 10, 2005 (edited) Here, I felt bad for mis-reading... this may work for you. You will need the beta to run this. #include <guiconstants.au3> #include <misc.au3> Opt("GUIOnEventMode", 1) GUICreate("", 400, 200) Dim $Tyre = GUICtrlCreateCombo ( "",160, 40, 150) GUICtrlSetData($Tyre,"Brand1|Brand2|Brand3","") GUISetOnEvent($GUI_EVENT_CLOSE, "EXIT_NOW") GUISetState() While 1 GUICtrlSetOnEvent($Tyre,"OnTyre") If _IsPressed("0D") = 1 Then If GUICtrlRead($Tyre) = "Brand1" Or GUICtrlRead($Tyre) = "Brand2" Or GUICtrlRead($Tyre) = "Brand3" Then OnTyre() EndIf Sleep(10) WEnd Func OnTyre() GUICtrlSetData($Tyre, GUICtrlRead($Tyre)) $Circumference = GUICtrlRead($Tyre) If GUICtrlRead ($Tyre) = "Brand1" OR GUICtrlRead ($Tyre) = "Brand2" Then $Circumference = 1.813 MsgBox(0, '', 'CIRCUMFERENCE = ' & $Circumference) ElseIf GUICtrlRead ($Tyre) = "Brand3" Then $Circumference = 1.816 MsgBox(0, '', 'CIRCUMFERENCE = ' & $Circumference) EndIf GUICtrlDelete($Tyre) $Tyre = GUICtrlCreateCombo ( "",160, 40, 150) GUICtrlSetData($Tyre,"Brand1|Brand2|Brand3","") EndFunc ;==>OnTyre Func EXIT_NOW() Exit EndFunc Edit: All you have to do is type the name and press enter, or scroll to item and click on it. Edited November 10, 2005 by ronsrules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
jefhal Posted November 10, 2005 Posted November 10, 2005 (edited) I still have the same problem.Try this please:#include <GuiConstants.au3> #include <GuiCombo.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") Opt('MustDeclareVars',1) dim $var Dim $Label,$Input,$Btn_Insert,$Combo,$Btn_Exit,$msg,$Status,$i_index GuiCreate("ComboBox Insert String", 392, 254) $Btn_Insert = GuiCtrlCreateButton("Add String", 210, 50, 90, 30) $Combo = GuiCtrlCreateCombo("A", 70, 100, 270, 100,$CBS_SIMPLE) GUICtrlSetData($Combo,"B|C|D|E|F") $Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30) $Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER)) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop Case _IsPressed("0D", $dll) WinActivate("ComboBox Insert String","") $var = ControlGetText("ComboBox Insert String", "", "Edit1") Sleep(200) ;ToolTip("_IsPressed",$var) $i_index = _GUICtrlComboInsertString($Combo,0,$var) EndSelect WEnd Exit Edited November 10, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
PartyPooper Posted November 10, 2005 Author Posted November 10, 2005 I guess there is more than one way to skin a cat. Thanks jefhal
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now