Help with Inventory Window control

Discuss coding questions, pull requests, and implementation details.
Post Reply
Asesino
Posts: 53
Joined: Fri Aug 16, 2019 3:14 am

Help with Inventory Window control

Post by Asesino »

Hi all, There was a bug report sent in for inventory filter. The user remapped Inventory from F6 to "I". Whenever he is typing in the filter, and presses "I", the inventory window closes. The filtertext box is using HotkeySequenceOverride but the closeBinding is not passing through any code that checks the value.

Code: Select all

        public override void Update()
        {
            base.Update();

            if (!DaggerfallUI.Instance.HotkeySequenceProcessed)
            {
                // Toggle window closed with same hotkey used to open it
                if (InputManager.Instance.GetKeyUp(toggleClosedBinding))
                    CloseWindow();
            }

            // Close window immediately if inventory suppressed
            if (suppressInventory)
            {
                CloseWindow();
                if (!string.IsNullOrEmpty(suppressInventoryMessage))
                    DaggerfallUI.MessageBox(suppressInventoryMessage);
                return;
            }
        }

In my test environment, i was able to get it working by changing the DaggerfallInventoryWindow.Update method as follows:

Code: Select all

        public override void Update()
        {
            base.Update();

            if (!DaggerfallUI.Instance.HotkeySequenceProcessed)
            {
                // Toggle window closed with same hotkey used to open it
                if (InputManager.Instance.GetKeyUp(toggleClosedBinding))
                    if (uiManager.TopWindow.FocusControl != null)
                    {
                        if (!uiManager.TopWindow.FocusControl.OverridesHotkeySequences)
                            CloseWindow();

                    } else
                    {
                        CloseWindow();
                    }
            }

            // Close window immediately if inventory suppressed
            if (suppressInventory)
            {
                CloseWindow();
                if (!string.IsNullOrEmpty(suppressInventoryMessage))
                    DaggerfallUI.MessageBox(suppressInventoryMessage);
                return;
            }
        }
 
I tried to place the logic into my UIWindow override but since I call base.Update() it didn't work. Am I looking at this correctly? Is the fix to update DaggerfallInvetoryWindow with a PR or is there a way to get my mod to handle the case?

thank you in advance for any assistance.
a

User avatar
pango
Posts: 2829
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Help with Inventory Window control

Post by pango »

The way UI windows are closed predates hotkeys, and does not uses it at all; So at least this is expected.
I don't know how hard it would be to change that, that was not one of my goals at the time, and it's been a while since I worked on that so I forgot most of keyboard handling intricacies...
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Asesino
Posts: 53
Joined: Fri Aug 16, 2019 3:14 am

Re: Help with Inventory Window control

Post by Asesino »

pango wrote: Tue Feb 23, 2021 9:20 pm The way UI windows are closed predates hotkeys, and does not uses it at all; So at least this is expected.
I don't know how hard it would be to change that, that was not one of my goals at the time, and it's been a while since I worked on that so I forgot most of keyboard handling intricacies...
Thank you pango, that makes sense. Given that I can't override it from within my mod. I will go ahead and submit a PR using the above approach.

Thanks again for the help!
a

Post Reply