Skip to content

Conversation

@IbraheemOsama
Copy link
Member

@IbraheemOsama IbraheemOsama commented Jul 4, 2017

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

@IbraheemOsama
Copy link
Member Author

@skendrot @nmetulev ping :)

@IbraheemOsama
Copy link
Member Author

@nmetulev @skendrot ping ping

@nmetulev
Copy link
Contributor

I'll try to review it this week

Copy link
Contributor

@nmetulev nmetulev left a 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
Copy link
Contributor

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

Copy link
Member Author

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>
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better than LayoutUpdated!!

Copy link
Member Author

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)
Copy link
Contributor

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?

Copy link
Member Author

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 :)

@IbraheemOsama
Copy link
Member Author

IbraheemOsama commented Aug 5, 2017

@nmetulev @skendrot I fixed issue #1352 #1267 #1266 and added underline to menuItem character if preceded by ^

Copy link
Contributor

@nmetulev nmetulev left a 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]"
Copy link
Contributor

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(),
Copy link
Contributor

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?

Copy link
Member Author

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);

Copy link
Contributor

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?

Copy link
Member Author

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>
Copy link
Contributor

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.

@IbraheemOsama
Copy link
Member Author

@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'
That's why I created FlyoutPlacement if you're at the bottom and you want the menu to show at the top you have to choose FlyoutPlacement and we just leave the placement to the developer.
We will provide the Auto for just the bottom and right Flyout. if you need top or left you'll have to use the FlyoutPlacement.
That's why I see FlyoutPlacement is useful and give a bit of space for the developer to choose :)

@nmetulev
Copy link
Contributor

nmetulev commented Aug 7, 2017

@IbraheemOsama, why not have Auto handle all the cases, is there a reason for that? Seems incomplete otherwise.

@IbraheemOsama
Copy link
Member Author

@nmetulev @skendrot I removed FlyoutPlacement

@nmetulev
Copy link
Contributor

Thanks @IbraheemOsama.

Sometimes the flyout shows up on the wrong side:
image

When menu is at the bottom, the flyout is aligned in the center, can it be left aligned?
image

Can you take a look?

@IbraheemOsama
Copy link
Member Author

@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" />
Copy link
Contributor

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"

@nmetulev
Copy link
Contributor

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).

@IbraheemOsama
Copy link
Member Author

@nmetulev you need to trust me more :P :) I changed the comment in the sample page

Copy link
Member

@michael-hawker michael-hawker left a 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">
Copy link
Member

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 ^?

Copy link
Member Author

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.

Copy link
Member Author

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()


### 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).
Copy link
Member

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" />
Copy link
Member

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'?


## 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.
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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;

Copy link
Member

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?

Copy link
Member Author

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 :)

Copy link
Member Author

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();
Copy link
Member

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?

Copy link
Member Author

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 :)

@IbraheemOsama
Copy link
Member Author

Now we can merge :)

@azchohfi azchohfi merged commit 6daff81 into CommunityToolkit:dev Aug 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants