kuangmk11, on 11 July 2013 - 07:17 PM, said:
This is nice evilC. Your scripts are great, I have co-opted several from my own use. I have a question:
when building the GUI can I call a subroutine when a value is changed in your formatting?
Example:
Regular AHK way:
Gui, Add, DropDownList, x22 y76 w60 h120 vNumWeapons gCalc, 1||2|3|4|5|6
ADHD way:
ADHD.gui_add("DropDownList", "NumWeapons", "xp+120 yp-2 W30 gCalc", "1|2|3|4|5|6", "1")
Seeing as all controls call the same subroutine (adhd_option_changed), you do not have to pass the g-label to gui_add for it to be able to add it.
Which you can see by examining gui_add:
gui_add(ctype, cname, copts, cparam3, cdef){
; Note this function assumes global so it can create gui items
Global
Gui, Add, %ctype%, %copts% v%cname% gadhd_option_changed, %cparam3%
this.ini_vars.Insert([cname,ctype,cdef])
}
The purpose of the adhd_option_changed function is primarily to alter the INI file so as to preserve user settings between runs.
Also, It is not actually that obvious from the AHK documentation, but you can alter the g-label of a control after you add it.
You can use something like
GuiControl, +gmy_new_subroutine, NumWeapons
So if you wished to do some of your own processing after the control changed, but before writing to the ini, you could do something like this:
[...]
ADHD.gui_add("DropDownList", "NumWeapons", "xp+120 yp-2 W30 gCalc", "1|2|3|4|5|6", "1")
GuiControl, +gmy_new_subroutine, NumWeapons
[...]
my_new_subroutine:
; insert your code here
; ...
; Call the option_changed routine afterwards to handle saving of options
Gosub, adhd_option_changed
return
Edited by evilC, 12 July 2013 - 05:13 AM.