LemonUIbyLemon / LemonUI

LemonUI for .NET (FiveM, RageMP, RagePluginHook and ScriptHookVDotNet 3)
MIT License
182 stars 41 forks source link

NativeListItem<T>.SelectedItem Setter doesn't set #71

Closed 07-stadia closed 2 years ago

07-stadia commented 2 years ago

Issue: When using setter of NativeListItem.SelectedItem, it doesn't select it in the menu. When e.g. the item '0' is in the list, and using SelectedItem = '0', item '0' doesn't get selected. Expected behavior: When e.g. the item '0' is in the list, using SelectedItem = '0', should select item '0'. Running similar code with RageNativeUI works fine. Environment Information LemonUI version: 1.7.0 RagePluginHookSDK: 1.86.1288.16169 .NET Framework: 4.7.2

LemonUI code snippet: `{ LemonUI.ObjectPool menuPool = new LemonUI.ObjectPool(); LemonUI.Menus.NativeMenu menu = new LemonUI.Menus.NativeMenu("Menu", ""); LemonUI.Menus.NativeListItem floatList = new LemonUI.Menus.NativeListItem("Float List", "", -10, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 10); LemonUI.Menus.NativeItem selectZero = new LemonUI.Menus.NativeItem("Float List Select 0");

Rage.GameFiber menuFiber;

menuPool.Add(menu);
menu.Add(floatList);
menu.Add(selectZero);

selectZero.Activated += (object sender, EventArgs e) =>
{
    floatList.SelectedItem = 0;
};

menuFiber = Rage.GameFiber.StartNew(() =>
{
    while (true)
    {
        menu.Process();
        Rage.GameFiber.Yield();
    }
}, "menuFiber");

menu.Visible = true;

while (true)
{
    if (!menu.Visible)
    {
        menuFiber.Abort();
        break;
    }

    Rage.GameFiber.Yield();
}

}`

RageNativeUI: `{ RAGENativeUI.MenuPool menuPool = new RAGENativeUI.MenuPool(); RAGENativeUI.UIMenu menu = new RAGENativeUI.UIMenu("Menu", ""); RAGENativeUI.Elements.UIMenuListScrollerItem floatList = new RAGENativeUI.Elements.UIMenuListScrollerItem("Float List", "", new List() { -10, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 10 }); RAGENativeUI.Elements.UIMenuItem selectZero = new RAGENativeUI.Elements.UIMenuItem("Float List Select 0");

        Rage.GameFiber menuFiber;

        menuPool.Add(menu);
        menu.AddItem(floatList);
        menu.AddItem(selectZero);

        selectZero.Activated += (_menu, item) =>
        {
            floatList.SelectedItem = 0;
        };

        menuFiber = Rage.GameFiber.StartNew(() =>
        {
            while (true)
            {
                menuPool.ProcessMenus();
                Rage.GameFiber.Yield();
            }
        }, "menuFiber");

        menu.Visible = true;

        while (true)
        {
            if (!menu.Visible)
            {
                menuFiber.Abort();
                break;
            }

            Rage.GameFiber.Yield();
        }
    }`
justalemon commented 2 years ago

Is easier to find bugs like this now that I'm using Rider instead of Visual Studio lol.

Also, check your code blocks, they were entered incorrectly and the code doesn't looks right :)

07-stadia commented 2 years ago

Wow, that was quick. I saw the code block already. Don't know how to fix it other then just removing it... Patiently waiting for the new update to drop.

justalemon commented 2 years ago

Well, the issue came in right after I finished #68 and I had Rider open so... yeah xd