fincs wrote:
toralf wrote:Do you plan to keep the old command style available in v2 or would this be a replacement?
This proposed design is intended as a replacement. As such, and in order not to alienate current AHK users, I designed it so that it stays as similar/parallel as possible as the old Gui API. Converting code to use the new Gui API is literally a matter of doing some minor tweaks to each line that uses a Gui command/function. Almost everything has a 1:1 correspondence.
I'm not a fan of removing the existing Gui commands. Obviously using the gui objects that you've designed is a step forward. But is there a way to make it more seamless?
Currently, v2 allows you to call commands with function syntax. So both of these work:
Code: Select all
;command syntax
Gui, Add, Text,, Please enter your name:
Gui, Add, Edit, vName
Gui, Show
;function syntax
Gui("Add", "Text", "", "Please enter your name:")
Gui("Add", "Edit", "vName")
Gui("Show")
The function syntax does some checking for a command that has an output var as the first parameter. If so, then that param is removed from the func param list and instead it becomes the return value for the function. Since the Gui commands have no return value, is it possible somehow return your new object? Perhaps only using the New subcommand? Something like, "To use the new OOP Gui's, call the
Gui, New command, but use the function syntax. The return value will be a new Gui Object. Like so:"
Code: Select all
;command syntax
Gui, New
;function syntax
gui_obj := Gui("New")
The
gui_obj var will contain your new Gui Object type, similar to how we have File/Func/ComObject's. Then we can use all of your existing Gui Object methods on it.
I guess on second look after rereading, this is simply the same as your
GuiCreate() func. So maybe my suggestion is to simply add your func (or rename it to
GuiObjCreate()) and keep all the Gui commands as is. This allows all existing v1 gui scripts to work while still adding your new functionality
Just my opinion, and I have no idea how feasible it is.