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

UIMenu.RemoveItemAt with only 1 item in the menu throws DivideByZeroException #160

Open
alexguirre opened this issue Apr 12, 2023 · 1 comment
Labels

Comments

@alexguirre
Copy link
Owner

Probably the issue is in this line that doesn't check for Items.Count == 0:

newSelection = Common.Wrap(newSelection + directionStep, 0, Items.Count);

@alexguirre alexguirre added the Bug label Apr 12, 2023
@Rohit685
Copy link

Workaround to the bug: Using the Clear() function to delete item when the MenuItems count is equal to 1

It would look something along the lines of:

 if (DeleteLocationMenu.MenuItems.Count == 1)
                {
                    DeleteLocationMenu.Clear();
                }
                else
                {
                    DeleteLocationMenu.RemoveItemAt(index);
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants