picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.57k stars 325 forks source link

[Mac] MenuItem.ShortCut always returns Keys.None #1284

Open brtn opened 5 years ago

brtn commented 5 years ago

menuItem.ShortCut always returns Keys.None on macOS. The related place is as far as I can see is this place:

https://github.com/picoe/Eto/blob/59c559d8d3affba153d92eb3601ef533a3ac5984/src/Eto.Mac/KeyMap.cs#L69

Expected Behavior

Assigned Keys value should be returned instead of Keys.None

Actual Behavior

It always returns Keys.None on macOS

Steps to Reproduce the Problem

  1. Access ShortCut property on a MenuItem instance on macOS

Code that Demonstrates the Problem

using Eto.Drawing;
using Eto.Forms;

namespace EtoApp
{
    public class MainForm : Form
    {

        public MainForm()
        {
            Title = "My Eto Form";
            ClientSize = new Size(400, -1);

            var layout = new StackLayout { Padding = 10 };
            layout.Items.Add(new Label { Text = "Right click for the context menu" });

            var command = new Command((s, a) => Console.WriteLine("It works")) { MenuText = "Console write", Shortcut = Keys.F2 };
            var buttonMenuItem = new ButtonMenuItem(command);
            layout.ContextMenu = new ContextMenu(buttonMenuItem);

            Console.WriteLine("Shortcut: " + buttonMenuItem.Shortcut); // -> This line does not print F2 on macOS

            Content = layout;
        }
    }
}

Specifications

cwensley commented 5 years ago

Thanks for submitting the issue! Looks like that code path was missed.