-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Changes to menuItemLocationChange #1285
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
Changes to menuItemLocationChange #1285
Conversation
…oft/menuitemLocationFix
|
I'll try to review it this week |
nmetulev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto FlyoutPlacement does not seem to work properly when changing orientation in run time. For example: in the sample app, starting with Horizontal orientation and then moving to Vertical, the flyouts show up on bottom instead on the right,
| /// <summary> | ||
| /// Defines constants that specify the preferred location for positioning the menu Flyout | ||
| /// </summary> | ||
| public enum MenuFlyoutPlacement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the file name doesn't match the name of the enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orientation and file name are fixed
|
|
||
| /// <summary> | ||
| /// Gets or sets the menu flyout placement | ||
| /// </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we need this new property and class? This should always be "auto". If the orientation is horizontal, then it's bottom or top (if the menu is at the bottom of the screen for some reason). If orientation is vertical it's either right or left
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the menu is at the middle of the screen !! I added it so it should be more fixable for user to choose whatever he wants and with "Auto" option we are supporting the default option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if, what if, what if... Menus have a predefined behavior. That's what should be supported. Even allowing a vertical orientation is a stretch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually agree with @skendrot on this one, It just seems like something that would be more trouble than worth. Should be all handled auto.
| } | ||
|
|
||
| private void MenuFlyout_Opened(object sender, object e) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better than LayoutUpdated!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the idea
|
|
||
| private bool AllowTooltip => (bool)GetValue(AllowTooltipProperty); | ||
|
|
||
| private static bool NavigateUsingKeyboard(object element, KeyEventArgs args, Menu menu, Orientation orientation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move all of this into a different file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was easier to search where are events and where are helper methods. the file was too big I should have planned the logic well from the beginning but we added many features during the PR :)
nmetulev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left few comments. In addition, when running the sample app with the menu in the bottom, the flyouts do not show up above the MenuItems as expected - instead they hide the MenuItems
Otherwise, love all the updated :)
|
|
||
| <controls:Menu AllowTooltip="@[AllowTooltip:Bool:True]" | ||
| <controls:Menu | ||
| AllowTooltip="@[AllowTooltip:Bool:False]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the formatting be fixed up in the bind file, it's a bit difficult to read?
|
|
||
| var runWithUnderlinedCharacter = new Run | ||
| { | ||
| Text = underlinedCharacter.ToString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TextDecorations is only available in CU, it will crash in AU or older. Maybe do a check before using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch :)
| } | ||
|
|
||
| var underlineCharacterIndex = _originalHeader.IndexOf(UnderlineCharacter); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work if ^ is at the end of the string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be removed in method HeaderPropertyChanged at line 496 :) so there is no need to check here again.
|
|
||
| /// <summary> | ||
| /// Gets or sets the menu flyout placement | ||
| /// </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually agree with @skendrot on this one, It just seems like something that would be more trouble than worth. Should be all handled auto.
|
@nmetulev regarding your comment 'when running the sample app with the menu in the bottom, the flyouts do not show up above the MenuItems as expected - instead they hide the MenuItems' |
|
@IbraheemOsama, why not have Auto handle all the cases, is there a reason for that? Seems incomplete otherwise. |
|
Thanks @IbraheemOsama. Sometimes the flyout shows up on the wrong side: When menu is at the bottom, the flyout is aligned in the center, can it be left aligned? Can you take a look? |
|
@nmetulev for the bottom menu, to align the menu to the left, we'll have to give it a custom position, I tried to apply the no space behavior to the bottom flyout but it behaved in a weird way. regarding the wrong side issue can you provide more details so I can debug, because I calculate based on the distance between right and left sides, if right side is closer I show the menu to the left etc. |
| <StackPanel Grid.Row="1"> | ||
| <TextBlock Text="Click Alt to set focus on Classic Menu" /> | ||
| <TextBlock Text="Any menu shortcut is Alt + (The first character of the menu name), ex to open File menu click Alt+F" /> | ||
| <TextBlock Text="To know any menu shortcut click Alt + (The underlined character in case underline ^ is used), ex to open File menu click Alt+F" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is unclear, could you update it to something along the lines of: Hold Alt to underline shortcut character. In code, ^ is used before the character you want highlighted"
|
I can no longer reproduce the placement issues so we should be good there. On the bottom and right placement, you are absolutely correct, there is no easy way to manage that. We should look into using custom control for the flyout in the future if there is a need for this. The only request is the text in the sample and we should be good to go (see comment above). |
|
@nmetulev you need to trust me more :P :) I changed the comment in the sample page |
michael-hawker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I don't think I have anything blocking, but if you could clean up a couple of the documentation based comments, that'd be great. Thanks!
| <controls:MenuItem x:Name="FileMenu" | ||
| controls:Menu.InputGestureText="Alt+F"> | ||
| controls:Menu.InputGestureText="Alt+F" | ||
| Header="^File"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed the SymbolIcon Header example was removed, can we not support both with the new ^?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add any template to the header, maybe a single Image or a stack panel or even a grid how can I know which element containing the text without work around :)
If it is requested then we could include an icon property in the menuItem or provide a way to access the required text element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed using FindChild()
docs/controls/Menu.md
Outdated
|
|
||
| ### TooltipPlacement | ||
| Gets or sets the tooltip PlacementMode on MenuItem. (Bottom,Right,Mouse,Left and Top) | ||
| Gets or sets the tooltip PlacementMode on MenuItem. (Bottom,Right,Mouse,Left and Top). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces between items in list?
| </controls:Menu> | ||
|
|
||
| <StackPanel Grid.Row="1"> | ||
| <TextBlock Text="Click Alt to set focus on Classic Menu" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update 'Click Alt' to be 'Press Alt'?
docs/controls/Menu.md
Outdated
|
|
||
| ## MenuItem Properties | ||
| ### Header | ||
| Gets or sets the header of the MenuItem. if you added '^' before any header character this character will be highlighted on clicking or holding Alt, this feature is used to visualize which character can be used beside Alt to open this MenuItem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> 'highlighted on pressing or holding Alt'
| } | ||
|
|
||
| private void MenuItem_LayoutUpdated(object sender, object e) | ||
| private void MenuFlyout_Opening(object sender, object e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this blank method to override a default behavior or something? If so, can you add a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch :) I was testing something but it seems I removed the event registration but didn't remove the event it self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that I didn't event remove the event registration :(
| } | ||
|
|
||
| menuItem._originalHeader = null; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to earlier comment: If the Header is an object, it'd be great if you could use FindChild<TextBlock>() to see if there's another text-based object you could grab from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that would help resolving the icon issue :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can included this in a next release as I'll not be available for creating new features until weekend (after code freeze).
| { | ||
| foreach (MenuItem item in Items) | ||
| { | ||
| item.Underline(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a future work item, support the MenuItem children as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can cover it in another release :)
|
Now we can merge :) |


Original PR #1284
Fixing issue #1293
Fixing another issue #1301
Fixing issue #1352
Fixing issue #1267
and Adding underline character on pressing Alt