ControlSetChecked() does not honor option '0' [unchecked]

Issue #91 closed
Winter Laite created an issue

AHK test script:

MyGui := Gui(, "Move Control")
Chk1 := MyGui.Add("CheckBox", "x10 y10", "Run")
Chk2 := MyGui.Add("CheckBox", "x10 y50", "Walk")
Chk3 := MyGui.Add("CheckBox", "x10 y90 h40 Checked 1", "Stay home")

ChkBtn1 := MyGui.Add("Button", "x10 y130 w80", "Toggle CBox 1")
ChkBtn1.OnEvent("Click", CheckOne)

ChkBtn2 := MyGui.Add("Button", "x10 y+10 w80", "Check CBox 2")
ChkBtn2.OnEvent("Click", CheckTwo)

ChkBtn3 := MyGui.Add("Button", "x10 y+10 w80", "Uncheck CBox 3")
ChkBtn3.OnEvent("Click", CheckThree)

MyGui.Show("w200 h350")

CheckOne(*) {
    ControlSetChecked(-1, Chk1)
}

CheckTwo(*) {
    ControlSetChecked(1, Chk2)
}

CheckThree(*) {
    ControlSetChecked(0, Chk3)
}

Failing Keysharp script:

MyGui := Gui(, "Move Control")
Chk1 := MyGui.Add("CheckBox", "x10 y10", "Run")
Chk2 := MyGui.Add("CheckBox", "x10 y50", "Walk")
Chk3 := MyGui.Add("CheckBox", "x10 y90 h40 Checked 1", "Stay home")

ChkBtn1 := MyGui.Add("Button", "x10 y130 w80", "Toggle CBox 1")
ChkBtn1.OnEvent("Click", "CheckOne")

ChkBtn2 := MyGui.Add("Button", "x10 y+10 w80", "Check CBox 2")
ChkBtn2.OnEvent("Click", "CheckTwo")

ChkBtn3 := MyGui.Add("Button", "x10 y+10 w80", "Uncheck CBox 3")
ChkBtn3.OnEvent("Click", "CheckThree")

MyGui.Show("w200 h350")

CheckOne() {
    ControlSetChecked(-1, Chk1)
}

CheckTwo() {
    ControlSetChecked(1, Chk2)
}

CheckThree() {
    ControlSetChecked(0, Chk3)
}

Instead of unchecking ChkBtn3, it will actually check it if it’s unchecked.

Comments (3)

  1. Log in to comment