Proposed New GUI API for AutoHotkey v2

Discuss the future of the AutoHotkey language
lexikos
Posts: 9552
Joined: 30 Sep 2013, 04:07
Contact:

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: 1204
Joined: 15 Nov 2014, 21:31
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: 6902
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/comma ... Create.htm
GuiCtrlFromHwnd
https://lexikos.github.io/v2/docs/comma ... omHwnd.htm
GuiFromHwnd
https://lexikos.github.io/v2/docs/comma ... omHwnd.htm

GUI Control Types
https://lexikos.github.io/v2/docs/comma ... ntrols.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/objec ... nEvent.htm
OnNotify
https://lexikos.github.io/v2/docs/objec ... Notify.htm
OnCommand
https://lexikos.github.io/v2/docs/objec ... ommand.htm
OnMessage
https://lexikos.github.io/v2/docs/comma ... essage.htm
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Ragnar
Posts: 611
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

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: 9552
Joined: 30 Sep 2013, 04:07
Contact:

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: 611
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

Gui.OnEvent("Close", "Gui_Close")
Gui.OnEvent("Escape", "Gui_Close")
would be then:

Code: Select all

Gui.OnEvent("Close Escape", "Gui_Close")
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Proposed New GUI API for AutoHotkey v2

27 May 2017, 08:22

The deactivation of notification handlers dosn't seem to work, or is there something wrong with this:

Code: Select all

   ; ===================================================================================================================
   ; ShowColors()    Sets ListView coloring on/off.
   ; Parameters:     Show        -  True/False
   ;                                Default: True
   ; Return Value:   True on success, otherwise false.
   ; ===================================================================================================================
   ShowColors(Show := True) {
      If !(This.HLV)
         Return False
      This.Ctl.OnNotify(0xFFFFFFF4, This.DrawFunc, !!Show) ; NM_CUSTOMDRAW = -12
      WinRedraw("ahk_id " . This.HLV)
      Return True
   }
I also tried to pass 0 directly.

Also, the Type() of GuiControl objects still contains "struct ".
lexikos
Posts: 9552
Joined: 30 Sep 2013, 04:07
Contact:

Re: Proposed New GUI API for AutoHotkey v2

28 May 2017, 02:01

Ragnar wrote:Gui.OnEvent("Close Escape", "Gui_Close")
(I seem to have missed your post.) I'd thought of that, but was getting tired of thinking about the GUI code. I was focused on making the API consistent, and was less concerned about convenience. There's room to add this and other "for convenience" features at any point in the future.

A more general idea was to allow chaining of methods; i.e. wherever a gui/control method has no other return value, return the gui/control object. However, that one has wider implications and probably requires careful consideration for each method. There might also be a more universal solution (which wouldn't require memorising which methods support chaining) - e.g. something like VB's with, which would work regardless of the method's return value, and with properties.
just me wrote:The deactivation of notification handlers dosn't seem to work
There was a bug. This one should work: AutoHotkey_2.0-a078-107+gaea90d6.zip
Also, the Type() of GuiControl objects still contains "struct ".
Yes, I'm well aware. It's a consequence of deriving the class names from the C++ type names, and fixing type() to just remove "struct " would be redundant at this point. It needs to be changed to allow each class to define its own type name. See Type(object).
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Proposed New GUI API for AutoHotkey v2

28 May 2017, 03:45

lexikos wrote:There was a bug. This one should work: AutoHotkey_2.0-a078-107+gaea90d6.zip
Yes, it seems to work now. Thanks!
lexikos wrote:See Type(object).
Sorry, I didn't remember this.
User avatar
lmstearn
Posts: 688
Joined: 11 Aug 2016, 02:32
Contact:

Re: Proposed New GUI API for AutoHotkey v2

30 May 2017, 07:26

Can't offer any grunt to this thread, but just the usual useless words of encouragement. Keep rowing boys! :D
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: lexikos and 30 guests