What would be a typical ahk way to do a edit form function for an item list? I've managed to do gui that lists a set of items with texts. Each item has an edit button and I want the textbox to be editable when edit is clicked. So it would need to change into an edit text control with an OK and cancel buttons. I guess it could be an additional modal gui or it could be in the original gui.
Are there any best practices or tutorials for this?
Item editor modal
Re: Item editor modal
At least two ways:
1. Controls can be disabled or set to read-only, so you could create toggles as you wish.
2. Listview also has its own read-only feature, and can accommodate a column of checkboxes.
Both are explained in the documentation.
1. Controls can be disabled or set to read-only, so you could create toggles as you wish.
2. Listview also has its own read-only feature, and can accommodate a column of checkboxes.
Both are explained in the documentation.
Re: Item editor modal
You could give your groups similar names, so that, for example, if you click on checkbox1, it enables edit1, checkbox2 enables edit2, and so on.
Re: Item editor modal
That is fine, too.
Re: Item editor modal
Hmmm I don't get it. If I have an unknown amount of items how could I set it up so that BtnEditX will show EditTextX and OkButtonX without knowing their number?
Re: Item editor modal
When you add a "row" or group, you can increment an item counter that then uses that counter in each of the variables or control names. You could try it with two or three groups to see how it works.
Re: Item editor modal
Would each row than have its own button handler that toggles the controls of that row?
Re: Item editor modal
Yes, as that is what I imagined you wanted, from your description.
Each item has an edit button and I want the textbox to be editable when edit is clicked. So it would need to change into an edit text control with an OK and cancel buttons.
Code: Select all
Gui, Font, s10
Gui, Add, Checkbox, vcheck1 gToggle
Gui, Add, Edit, x+m vedit1 w100
Gui, Show, w190, Test
editToggle("edit1")
Return
Toggle:
editToggle(StrReplace(A_GuiControl, "check", "edit"))
Return
GuiEscape:
GuiClose:
ExitApp
editToggle(control) {
GuiControlGet, enabled, Enabled, %control%
GuiControl, % (enabled ? "Disable" : "Enable"), %control%
GuiControl, Focus, %control%
}
Re: Item editor modal
Yes exactly. OK I get it. So when I declare a label for a handler I can use variables in its name as well?
Like
ItemEditButtonClicked%index%:
;OnClick logic here
Re: Item editor modal
Sure.
Code: Select all
Gui, Font, s10
Loop, 2 {
Gui, Add, Checkbox, xm vcheck%A_Index% gToggle
Gui, Add, Edit, x+m vedit%A_Index% w100
editToggle("edit" A_Index)
}
Gui, Show, w190, Test
Return
Toggle:
editToggle(StrReplace(A_GuiControl, "check", "edit"))
Return
GuiEscape:
GuiClose:
ExitApp
editToggle(control) {
GuiControlGet, enabled, Enabled, %control%
GuiControl, % (enabled ? "Disable" : "Enable"), %control%
GuiControl, Focus, %control%
}
Who is online
Users browsing this forum: filipemb, haomingchen1998, mikeyww, Oblomov228, RussF and 274 guests