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

Gui, new not name case miss #202

Open
CoffeeChaton opened this issue Jun 20, 2024 · 3 comments
Open

Gui, new not name case miss #202

CoffeeChaton opened this issue Jun 20, 2024 · 3 comments

Comments

@CoffeeChaton
Copy link

V1:

#Requires AutoHotkey v1.1.33.11
#SingleInstance Force
#Warn All, MsgBox

Gui, guiName:new
Gui, Add, text,, % "text              text                text       text"
Gui, Add, Button, Default, AAAA
Gui, Show

Gui, new ; not name
Gui, Add, text,, % "text2              text2                text2       text2"
Gui, Add, Button, Default, BBBB
Gui, Show

return

guiNameButtonAAAA() {
    ; Gui, Add, Button, Default, AAAA
    ; guiName + Button + AAAA
    ; guiNameButtonAAAA
    MsgBox, % "Button AAAA is call"
}

ButtonBBBB() {
    MsgBox, % "Button BBBB is call"
}

GuiClose:
GuiEscape:
ExitApp

V2 (Converted):

#Requires Autohotkey v2.0
#SingleInstance Force
#Warn All, MsgBox

guiName := Gui()
guiName.Add("text", , "text              text                text       text")
ogcButtonAAAA := guiName.Add("Button", "Default", "AAAA")
ogcButtonAAAA.OnEvent("Click", guiNameButtonAAAA.Bind("Normal"))
guiName.Show()


 ; not name
guiName.Add("text", , "text2              text2                text2       text2")
ogcButtonBBBB := guiName.Add("Button", "Default", "BBBB")
ogcButtonBBBB.OnEvent("Click", guiNameButtonBBBB.Bind("Normal"))
guiName.Show()

return

guiNameButtonAAAA() {
    ; Gui, Add, Button, Default, AAAA
    ; guiName + Button + AAAA
    ; guiNameButtonAAAA
    MsgBox("Button AAAA is call")
}

ButtonBBBB() {
    MsgBox("Button BBBB is call")
}

GuiClose:
GuiEscape:
ExitApp()

V2 (Expected):

#Requires Autohotkey v2.0
#SingleInstance Force
#Warn All, MsgBox

guiName := Gui()
guiName.Add("text", , "text              text                text       text")
ogcButtonAAAA := guiName.Add("Button", "Default", "AAAA")
ogcButtonAAAA.OnEvent("Click", guiNameButtonAAAA.Bind("Normal"))
guiName.Show()


myGui := Gui()
myGui.OnEvent("Close", GuiClose)
myGui.OnEvent("Escape", GuiClose)
; not name
myGui.Add("text", , "text2              text2                text2       text2")
ogcButtonBBBB := myGui.Add("Button", "Default", "BBBB")
ogcButtonBBBB.OnEvent("Click", ButtonBBBB.Bind("Normal"))
myGui.Show()

return

guiNameButtonAAAA() {
    ; Gui, Add, Button, Default, AAAA
    ; guiName + Button + AAAA
    ; guiNameButtonAAAA
    MsgBox("Button AAAA is call")
}

ButtonBBBB() {
    MsgBox("Button BBBB is call")
}

GuiClose(*)
{ ; V1toV2: Added bracket
    global ; V1toV2: Made function global
    GuiEscape:
    ExitApp()
} ; Added bracket in the end

Expected is use Gui, 1:new ; not name to converted

@andymbody
Copy link
Contributor

FYI... I added this as a failed test to my most recent local repo. So the failed test might be part of my next PR. I don't plan to fix it just yet, just added the failed test.

@Banaanae
Copy link
Collaborator

Banaanae commented Jul 1, 2024

I have a basic fix done (fixes below)

Gui, Add, Text, w250, Gui 1
Gui, Show

Gui, New
Gui, Add, Text, w200, Gui 2
Gui, Show
myGui := Gui()
myGui.Add("Text", "w250", "Gui 1")
myGui.Show()

myGui1 := Gui()
myGui1.Add("Text", "w200", "Gui 2")
myGui1.Show()

But it also somehow broke your script worse? How fun
Nevermind, but this script breaks the convertor in serveral ways

@Banaanae Banaanae reopened this Jul 1, 2024
@Banaanae
Copy link
Collaborator

Banaanae commented Jul 1, 2024

not quite fixed yet :)
The gui, new part is fixed, but the following isn't:

  • The labels aren't converted (seems Gui, guiName:new breaks it)
  • The button callback params aren't correct
  • Assumed callback linking (ill make its own issue)

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

3 participants