Receive command keys for close/save for editor in tabpanel

Good afternoon (o;

My work goes on with my FPGA IDE…

Switched to SyntaxArea.Editor now for handling the source files and started from scratch a simple tab panel for them.

What is the most elegant way to react in macOS command keys, like when an editor tab is active, that it receives the command keys like save/close?

Current look now (o;

If you have a menu item for Close Tab, you’ll get an event.

Okay…added this code in ConstructContextualMenu

Var item As New DesktopMenuItem("Close")
item.Shortcut = "cmd-w"
base.AddMenu(item)

With right-click the event is triggered, but I see that the Command-W shortcut is grayed out in the menu, therefore not triggering anything.

Cmd-W is not used anywhere else though.

Grayed out is normal
Are you trying Cmd-w when the contextual menu shows? or you want Cmd-w to be available even if the contextual menu is not showing?

Edit:
screencast2024-08-261PM-05-57-ezgif.com-video-to-gif-converter

Would be nice if Cmd-W would work even when the contextual menu isn’t shown.

But maybe it is probably best to use the MainMenu handler for this and figure out there which file to close or save as all files are in the custom canvas tab panel.

For the code you showed, Cmd-W is only available when the contextual menu is created (every time you right click).

1 Like

Ah okay…you’re right…just wondering why it is grayed out then…

So there is no way to make a Shortcut work for a contextual menu item on a canvas?

Does a shortcut on a contextual menu even make sense? After all, until you right-click, the contextual menu does not exist.

Whereas the regular menu-bar and its menus do exist, just not showing.

1 Like

Ah that makes perfect sense (o;

Just still learning and trying new things…but from the user perspective, which is actually only me right now, a contextual menu would be overloaded.

Haven’t seen that on similar FPGA synthesis IDEs.

I’ll stick with the MainMenu events and dispatch from there what to do (o;