Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Gui, Submit when there are multiple GUIs #232

Open
Banaanae opened this issue Jul 6, 2024 · 0 comments
Open

Issue with Gui, Submit when there are multiple GUIs #232

Banaanae opened this issue Jul 6, 2024 · 0 comments

Comments

@Banaanae
Copy link
Collaborator

Banaanae commented Jul 6, 2024

V1:

Gui, Add, Text,, Gui Number 1
Gui, Add, Edit, vEdit1, I love to edit
Gui, Add, Button, gOpen2Gui, Open GUI 2
Gui, Add, Button, gSumbitResults, Submit my edit
Gui, Show, w150
Return

Open2Gui:
Gui, New
Gui, Add, Text,, Gui Number 2
Gui, Add, Edit, vEdit2, I love to button
Gui, Add, Button, gSumbitResults, Submit my edit
Gui, Show, w100
Return

SumbitResults:
Gui, Submit
MsgBox % Edit1
Return

V2 (Converted):

myGui := Gui()
myGui.Add("Text", , "Gui Number 1")
ogcEdit1 := myGui.Add("Edit", "vEdit1", "I love to edit")
ogcButtonOpenGUI2 := myGui.Add("Button", , "Open GUI 2")
ogcButtonOpenGUI2.OnEvent("Click", Open2Gui.Bind("Normal"))
ogcButtonSubmitmyedit := myGui.Add("Button", , "Submit my edit")
ogcButtonSubmitmyedit.OnEvent("Click", SumbitResults.Bind("Normal"))
myGui.Show("w150")
Return

Open2Gui(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *)
{ ; V1toV2: Added bracket
global ; V1toV2: Made function global
myGui1 := Gui()
myGui1.Add("Text", , "Gui Number 2")
ogcEdit2 := myGui1.Add("Edit", "vEdit2", "I love to button")
ogcButtonSubmitmyedit := myGui1.Add("Button", , "Submit my edit")
ogcButtonSubmitmyedit.OnEvent("Click", SumbitResults.Bind("Normal"))
myGui1.Show("w100")
Return
} ; V1toV2: Added Bracket before label

SumbitResults(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *)
{ ; V1toV2: Added bracket
global ; V1toV2: Made function global
oSaved := myGui1.Submit()
Edit2 := oSaved.Edit2
MsgBox(Edit1)
Return
} ; V1toV2: Added bracket in the end

V2 (Expected):

myGui := Gui()
myGui.Add("Text", , "Gui Number 1")
ogcEdit1 := myGui.Add("Edit", "vEdit1", "I love to edit")
ogcButtonOpenGUI2 := myGui.Add("Button", , "Open GUI 2")
ogcButtonOpenGUI2.OnEvent("Click", Open2Gui.Bind("Normal"))
ogcButtonSubmitmyedit := myGui.Add("Button", , "Submit my edit")
ogcButtonSubmitmyedit.OnEvent("Click", SumbitResults.Bind("Normal"))
myGui.Show("w150")
Return

Open2Gui(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *)
{ ; V1toV2: Added bracket
global ; V1toV2: Made function global
myGui1 := Gui()
myGui1.Add("Text", , "Gui Number 2")
ogcEdit2 := myGui1.Add("Edit", "vEdit2", "I love to button")
ogcButtonSubmitmyedit := myGui1.Add("Button", , "Submit my edit")
ogcButtonSubmitmyedit.OnEvent("Click", SumbitResults.Bind("Normal"))
myGui1.Show("w100")
Return
} ; V1toV2: Added Bracket before label

SumbitResults(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *)
{ ; V1toV2: Added bracket
global ; V1toV2: Made function global
try oSaved := myGui.Submit()
try oSaved1 := myGui1.Submit()
try Edit1 := oSaved.Edit1
try Edit2 := oSaved1.Edit2
MsgBox(Edit1)
Return
} ; V1toV2: Added bracket in the end

Original GUI gets missed
Append all lines with try (some GUIs aren't open, so the return nothing)
For a better example of this see #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant