-
Notifications
You must be signed in to change notification settings - Fork 703
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
Setting Menus
causes unexpected Exception
#3652
Comments
I already facing this issue with the |
Maybe a good solution would be to hold the shortcuts collection in a member and evaluating them 'just in time' at the keybinding resolution step? In this approach we would not modify |
There is no need to modify the |
Sorry I meant maybe we can avoid modifying the KeyBindings instance (in memory) - not code changes. In this case we would just look at the shortcuts as part of key resolution rather than trying to add/remove keybindings? So it would be something like: /// <inheritdoc />
public override bool? OnInvokingKeyBindings (Key keyEvent, KeyBindingScope scope)
{
foreach (var shortcut in Menus)
{
if (shortcut.HotKey == keyEvent.KeyCode)
{
// Do thing
return true;
}
}
return base.OnInvokingKeyBindings (keyEvent, scope);
} |
But there another issue on the |
Why? why not just use the first when it finds a collision at runtime? we don't really need this to be an Exception do we? |
Of course not. That why I'm working on this now and I'm not getting any exception with keybinding now. I'm still work with code that will handing updating with properties changed. Because of the collision I found this bug in the menu and thus it's benefic it throw an exception in these situations. |
I would like suggest to change the if (string.IsNullOrEmpty (text))
{
//key = Key.Empty;
key = null;
//return true;
return false;
} |
Key.Empty == null. |
Regardless of the meaning of Key.Empty v null, it is my understanding that the semantics of a "TryXXX" method is if it returns false the value of the out params are indeterminate. IOW if there is code that relies on an out parameter not being changed when false is returned that code is buggy. |
It isn't the case I'll set the |
|
I'll change the |
Describe the bug
MenuBar.Menus magic property behaves inconsistently when set multiple times.
The setter should replace existing values with the new values.
Regarding the new Exception that is throw, it is problematic for designer where user might easily create multiple menu items with the same name or shortcut key.
For this use case we need a setting which suppress the Exception.
Test
Throws
The text was updated successfully, but these errors were encountered: