Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: When passing a GUI to a for-loop, have the values be marked as Gui.Control type. #486

Closed
GroggyOtter opened this issue Mar 5, 2024 · 3 comments

Comments

@GroggyOtter
Copy link

GroggyOtter commented Mar 5, 2024

Would you please consider updating the addon so when a gui object is passed to a for-loop, it treats the provided values as Gui.Control objects.
This would provide the proper methods and properties to those values when used in the for-loops code block.

Example:

goo := Gui()
con := goo.AddText()
con.

Accessing con produces the expected autocomplete widget with properties and methods.

However, when the controls are gotten from the for-loop, the addon assigns no "type" to them, preventing autocomplete from activating and populating with the properties and methods of the Gui.Control class:

goo := Gui()
goo.AddText()
for con in goo
    con.

Fails to produce any type of autocomplete widget.

Obviously, it would be difficult to determine each individual control's type, such as Gui.Button or Gui.Edit, but they could blanket-labeled as Gui.Control types, thus providing the basic properties and methods that all gui controls possess.

@thqby
Copy link
Owner

thqby commented Mar 6, 2024

This statement is not supported at present. You can mark the variable type.

goo := Gui()
goo.AddText()
/** @type {Gui.Control} */
con := unset
for con in goo
    con.

@GroggyOtter
Copy link
Author

This statement is not supported at present. You can mark the variable type.

goo := Gui()
goo.AddText()
/** @type {Gui.Control} */
con := unset
for con in goo
    con.

I'm aware that you can premark a variable with a tag.
But this should be a default behavior of the addon. The addon knows a GUI is being passed to the for-loop. It's only logical the value be marked as a control as that's how iteration of GUI works.
Having to make a tag prior to every for-loop is is unintuitive and defeats the point of having such features in a text editor.

thqby added a commit that referenced this issue Mar 11, 2024
@thqby
Copy link
Owner

thqby commented Mar 11, 2024

class Gui<ControlType = Gui.Control | Gui.List | Gui.ListView | Gui.StatusBar | Gui.Tab | Gui.TreeView> extends Object {
/**
* Retrieve or set the background color of the window.
*/
BackColor {
get => String
set => void
}
/**
* Retrieve the GuiControl object of the focus control of the GUI.
*/
FocusedCtrl => ControlType
/**
* Retrieve the window handle (HWND) of the GUI window.
*/
Hwnd => Integer
/**
* Retrieve or set the size of the horizontal margin between the two sides and the subsequently created control.
*/
MarginX {
get => Integer
set => void
}
/**
* Retrieve or set the size of the vertical margin between the two sides and the subsequently created control.
*/
MarginY {
get => Integer
set => void
}
/**
* Retrieve or set the menu bar of the window.
*/
MenuBar {
get => MenuBar
set => void
}
/**
* Retrieve or set the custom name of the GUI window.
*/
Name {
get => String
set => void
}
/**
* Retrieve or set the title of the GUI.
*/
Title {
get => String
set => void
}
/**
* Create a new Gui object.
* @param Options AlwaysOnTop Border Caption Disabled -DPIScale LastFound
* MaximizeBox MinimizeBox MinSize600x600 MaxSize800x800 Resize
* OwnDialogs '+Owner' OtherGui.hwnd +Parent
* SysMenu Theme ToolWindow
* @param Title The window title. If omitted, it defaults to the current value of A_ScriptName.
* @param EventObj OnEvent, OnNotify and OnCommand can be used to register methods of EventObj to be called when an event is raised
*/
__New([Options, Title := A_ScriptName, EventObj]) => void
/**
* Enumerates the GUI's controls.
*/
__Enum(NumberOfVars?) => Enumerator<ControlType> | Enumerator<Integer, ControlType>

See ahk2.d.ahk for changes.

@thqby thqby closed this as completed Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants