Now on to the reason for the post.
I have a DropDownList with a Change event that modifies the textcolor and backcolor of an object. However, in the gui itself, the field does not update and remains (visually) the same color. I thought using Redraw() would do the trick, but it does not. Neither does making the field hidden then visible. Am I missing some key components? Here is a sample of the code I am using:
Code: Select all
#SingleInstance Force
#Requires AutoHotkey v2.0
customColorsMap := Map(1, Map("text", "FF8080", "back", "black"), 2, Map("text", "FFFF80", "back", "black"), 3, Map("text", "80FF80", "back", "black"), 4, Map("text", "80FFFF", "back", "black"), 5, Map("text", "0080FF", "back", "black"), 6, Map("text", "FF80c0", "back", "black"), 7, Map("text", "red", "back", "black"), 8, Map("text", "0080c0", "back", "black"), 9, Map("text", "fuchsia", "back", "black"), 10, Map("text", "804040", "back", "black"), 11, Map("text", "FF8040", "back", "black"), 12, Map("text", "teal", "back", "black"), 13, Map("text", "004080", "back", "black"), 14, Map("text", "FF0080", "back", "black"), 15, Map("text", "green", "back", "black"), 16, Map("text", "blue", "back", "black"))
PInfo := Gui("+Resize +MinSize500x25", "Dynamic Color Viewer")
tcustomColorE := PInfo.Add("DropDownList", "w140 h300 Choose1", ["(no change)", "Custom1", "Custom2", "Custom3", "Custom4", "Custom5", "Custom6", "Custom7", "Custom8", "Custom9", "Custom10", "Custom11", "Custom12", "Custom13", "Custom14", "Custom15", "Custom16", "Other"])
tcustom_sampleText := PInfo.Add("Edit", "xp+200 yp w100 h16 Hidden Center", "Sample text")
tcustomColorE.OnEvent("Change", customColorChange)
PInfo.Show
customColorChange(thisDDL, info)
{
if (thisDDL.value == 1)
{
tcustom_sampleText.Visible := false
return
}
tcustom_sampleText.Visible := false
tcustom_sampleText.TextColor := customColorsMap[thisDDL.value - 1]["text"]
tcustom_sampleText.BackColor := customColorsMap[thisDDL.value - 1]["back"]
tcustom_sampleText.Redraw()
tcustom_sampleText.Visible := true
}