TreeView not working correctly.

Issue #12 closed
Winter Laite created an issue

Test script:

MyGui := Gui()
TV := MyGui.Add("TreeView", "-ReadOnly")
TV.OnEvent("ItemEdit", "MyTree_Edit")  ; Call MyTree_Edit whenever a user has finished editing an item.
P1 := TV.Add("First parent")
P1C1 := TV.Add("Parent 1's first child", P1)  ; Specify P1 to be this item's parent.
P2 := TV.Add("Second parent")
P2C1 := TV.Add("Parent 2's first child", P2)
P2C2 := TV.Add("Parent 2's second child", P2)
P2C2C1 := TV.Add("Child 2's first child", P2C2)

MyGui.Show()  ; Show the window and its TreeView.


MyTree_Edit(TV, Item)
{
    TV.Modify(TV.GetParent(Item), "Sort")  ; This works even if the item has no parent.
}

@Cloaker suggested a fix on the Discord - I will update this if I can find it again. The working image is from the @Cloaker fix.

Comments (5)

  1. Winter Laite reporter

    I found the @Cloaker edit for Map.cs, which apparently fixed the TreeView issue, although I don’t recall testing that before.

    looks like GetPos builds a Keysharp.Core.Map out of a Dictionary<string, object> but Keysharp.Core.Map's constructor/setter only handles arrays of keys/values, not a dictionary of them
    you can edit Core/Map.cs:166 (Keysharp.Core.Map's Set()  method) and stick
    
                if (values.Length == 1 && values[0] is Dictionary<string, object> tempm)
                {
                    _ = map.EnsureCapacity(tempm.Count);
                    foreach (var (k, v) in tempm)
                        Insert(k, v);
                    return;
                }
    

  2. Log in to comment