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

Assumed automatic g-labels not converted with multiple GUIs #224

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

Assumed automatic g-labels not converted with multiple GUIs #224

Banaanae opened this issue Jul 2, 2024 · 0 comments

Comments

@Banaanae
Copy link
Collaborator

Banaanae commented Jul 2, 2024

From docs:

If a button lacks an explicit g-label, an automatic label is assumed. For example, if the first GUI window contains an OK button, the ButtonOK label (if it exists) will be launched when the button is pressed. For GUI windows other than the first, the window number is included in front of the button's automatic label; for example: 2ButtonOK.

Needs to handle both labels and functions, and multiple guis

Example 1

V1:

Gui1Pos := A_ScreenHeight // 2 * 0.7

Gui, Add, Button,, Button 1
Gui, Add, Button, ys, Button 2
Gui, Show, y%Gui1Pos%

Gui, New
Gui, Add, Button,, Button 3
Gui, Add, Button, ys, Button 4
Gui, Add, Button, ys, Button 5
Gui, Show
Return

ButtonButton1() {
MsgBox, First Button Pressed
Return
}

ButtonButton2:
MsgBox, Second Button Pressed
Return

ButtonButton3:
MsgBox, Third Button Pressed
Return

ButtonButton4() {
MsgBox, Fourth Button Pressed via %A_GuiEvent%
Return
}

V2 (Converted):

Gui1Pos := A_ScreenHeight // 2 * 0.7

myGui := Gui()
ogcButtonButton1 := myGui.Add("Button", , "Button 1")
ogcButtonButton1.OnEvent("Click", ButtonButton1.Bind("Normal"))
ogcButtonButton2 := myGui.Add("Button", "ys", "Button 2")
ogcButtonButton2.OnEvent("Click", ButtonButton2.Bind("Normal"))
myGui.Show("y" . Gui1Pos)

myGui1 := Gui()
ogcButtonButton3 := myGui1.Add("Button", , "Button 3")
ogcButtonButton3.OnEvent("Click", myGui1ButtonButton3.Bind("Normal"))
ogcButtonButton4 := myGui1.Add("Button", "ys", "Button 4")
ogcButtonButton4.OnEvent("Click", myGui1ButtonButton4.Bind("Normal"))
ogcButtonButton5 := myGui1.Add("Button", "ys", "Button 5")
ogcButtonButton5.OnEvent("Click", myGui1ButtonButton5.Bind("Normal"))
myGui1.Show()
Return

ButtonButton1() {
MsgBox("First Button Pressed")
Return
}

ButtonButton2(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *)
{ ; V1toV2: Added bracket
global ; V1toV2: Made function global
MsgBox("Second Button Pressed")
Return
} ; V1toV2: Added Bracket before label

ButtonButton3:
MsgBox("Third Button Pressed")
Return

ButtonButton4() {
MsgBox("Fourth Button Pressed via " A_GuiEvent)
Return
}

V2 (Expected):

Gui1Pos := A_ScreenHeight // 2 * 0.7

myGui := Gui()
ogcButtonButton1 := myGui.Add("Button", , "Button 1")
ogcButtonButton1.OnEvent("Click", ButtonButton1.Bind("Normal"))
ogcButtonButton2 := myGui.Add("Button", "ys", "Button 2")
ogcButtonButton2.OnEvent("Click", ButtonButton2.Bind("Normal"))
myGui.Show("y" . Gui1Pos)

myGui1 := Gui()
ogcButtonButton3 := myGui1.Add("Button", , "Button 3")
ogcButtonButton3.OnEvent("Click", ButtonButton3.Bind("Normal"))
ogcButtonButton4 := myGui1.Add("Button", "ys", "Button 4")
ogcButtonButton4.OnEvent("Click", ButtonButton4.Bind("Normal"))
ogcButtonButton5 := myGui1.Add("Button", "ys", "Button 5")
myGui1.Show()
Return

ButtonButton1(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *) {
MsgBox("First Button Pressed")
Return
}

ButtonButton2(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *)
{ ; V1toV2: Added bracket
global ; V1toV2: Made function global
MsgBox("Second Button Pressed")
Return
} ; V1toV2: Added Bracket before label

ButtonButton3(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *)
{ ; V1toV2: Added bracket
global ; V1toV2: Made function global
MsgBox("Third Button Pressed")
Return
} ; V1toV2: Added Bracket before label

ButtonButton4(A_GuiEvent := "", GuiCtrlObj := "", Info := "", *) {
MsgBox("Fourth Button Pressed via " A_GuiEvent)
Return
}
@Banaanae Banaanae changed the title Assumed automatic g-labels not converted with multiple GUIs or stacked labels Assumed automatic g-labels not converted with multiple GUIs Jul 2, 2024
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