Proposed New GUI API for AutoHotkey v2

Discuss the future of the AutoHotkey language
lexikos
Posts: 5270
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Proposed New GUI API for AutoHotkey v2

18 May 2017, 03:18

Flipeador, scroll up to "Do you intend to implement CtrlObj.Destroy()?" (on page 12, same as your post)
User avatar
Flipeador
Posts: 281
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: Proposed New GUI API for AutoHotkey v2

18 May 2017, 08:13

Ooh! i remember now. I think I've read it before. I'm too forgetful. :facepalm:
Thanks. :)
User avatar
jeeswg
Posts: 1029
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Proposed New GUI API for AutoHotkey v2

18 May 2017, 09:02

Some thoughts:
- is there an option: GUI specify class name/hIcon/WNDCLASSEX
- ... and/or: GUI take control of a GUI window created by same script via DllCall?
- date control: SetFormat, Choose (but what about GetFormat, GetValue (number), GetText (appearance)?) (although for example, you could have read/write Format property, read/write Value property, read-only Text property) [EDIT: these is some '.Value' functionality]
- also, why 'Ctrl' rather than 'Ctl', isn't 'Ctl' far more common, and less prone to confusion with the Ctrl key?

Btw for anyone interested in testing there is some documentation available now:

GuiCreate
https://lexikos.github.io/v2/docs/commands/GuiCreate.htm
GuiCtrlFromHwnd
https://lexikos.github.io/v2/docs/commands/GuiCtrlFromHwnd.htm
GuiFromHwnd
https://lexikos.github.io/v2/docs/commands/GuiFromHwnd.htm

GUI Control Types
https://lexikos.github.io/v2/docs/commands/GuiControls.htm
ListView (GUI)
https://lexikos.github.io/v2/docs/commands/ListView.htm
TreeView (GUI)
https://lexikos.github.io/v2/docs/commands/TreeView.htm

GUI Object
https://lexikos.github.io/v2/docs/objects/Gui.htm
OnEvent
https://lexikos.github.io/v2/docs/objects/GuiOnEvent.htm
OnNotify
https://lexikos.github.io/v2/docs/objects/GuiOnNotify.htm
OnCommand
https://lexikos.github.io/v2/docs/objects/GuiOnCommand.htm
OnMessage
https://lexikos.github.io/v2/docs/commands/OnMessage.htm
User avatar
Ragnar
Posts: 86
Joined: 30 Sep 2013, 15:25

Re: Proposed New GUI API for AutoHotkey v2

18 May 2017, 16:32

Are there any reasons why GuiCtrlObj := Gui.Control[Name] is not a method?

Compared to the other properties, its behaviour is awkward and not necessarily predictable. For example:

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui := GuiCreate()
Gui.Add("Edit", "vName")
Gui.Show()

; When assuming an array of controls would be returned without property:
MsgBox(Gui.Control) ; -> Invalid usage error
; When assuming the default property syntax works here too:
MsgBox(Gui.Control.Name) ; -> Invalid usage error

In my opinion, it's almost predestined to be a method.

Maybe it could be somehow merged with Gui._NewEnum, in which case it could return an array of GuiControl objects, if Gui.Control's parameter is omitted.
lexikos
Posts: 5270
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Proposed New GUI API for AutoHotkey v2

18 May 2017, 22:02

Ragnar wrote:Are there any reasons why GuiCtrlObj := Gui.Control[Name] is not a method?
It's a collection of objects belonging to the GUI. That's a property in the general sense. You can't retrieve the collection itself now, but maybe in the future. (It is low priority due to the fact that adding it later won't break anything.)

Properties a script defines with parameters (for the getter/setter) are no different. RegExMatch also has a few properties like this, but allows () as well due to ambiguity (with named patterns). COM objects also have properties with parameters, but again, () can be used due to the way IDispatch works.

The behaviour is predictable. Use the syntax shown in the documentation, and it will work. Use other syntax, and it won't.
User avatar
Ragnar
Posts: 86
Joined: 30 Sep 2013, 15:25

Re: Proposed New GUI API for AutoHotkey v2

19 May 2017, 07:19

For Gui.OnEvent and/or GuiCtrl.OnEvent, what about chaining events which have the same Callback parameter (like jQuery's .On()). For Example:

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui.OnEvent("Close", "Gui_Close")
Gui.OnEvent("Escape", "Gui_Close")

would be then:

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui.OnEvent("Close Escape", "Gui_Close")

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: HotKeyIt and 3 guests