Bug 13100 - accelerator keys do not work in embedded NSViews
Summary: accelerator keys do not work in embedded NSViews
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: unspecified
Hardware: PC Mac OS
: --- major
Target Milestone: master
Assignee: Mikayla Hutchinson [MSFT]
Depends on:
Reported: 2013-07-08 15:33 UTC by Alan McGovern
Modified: 2015-01-14 16:14 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

This implements cut, copy, paste and select all (2.76 KB, patch)
2013-07-26 08:53 UTC, Michael Natterer

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Alan McGovern 2013-07-08 15:33:01 UTC
We have an NSTextField inside an NSView which is inside a GtkNSView. I can type into the NSTextField with no issue, but if I press command-A (for select-all), command-c (for copy) or command-v (for paste) nothing happens.
Comment 1 Michael Natterer 2013-07-09 07:38:53 UTC
This is very tricky. I don't really see how to handle these because GTK+
gets all key events (they go to the toplevel, so to GTK+/the app).

Unless somebody has a wonderful idea I miss, I can only think of adding
support for some hand-picked ones per *application*, as in:

In the action callbacks for command-A, command-C etc, check if the
currently focused widget is a GtkNSView, then check if the NSView inside
that has first responder is a NSTextFiels, then handle the commands

I'm thinking hard, but please drop me any other idea :)
Comment 2 Alan McGovern 2013-07-09 10:10:22 UTC
If I understand what you're describing you're suggesting we track 'command-c' at the gtk level and then poke inside the NSView hierarchy to find a widget which we think we can 'copy' from and then manually do that copy.

I thought the issue was more that the widget was not getting the right key events from gtk.
Comment 3 Michael Natterer 2013-07-09 10:33:53 UTC
I verified that the NSView gets the event, but that doesn't seem to help.
There must be some higher level logic in place that makes this happen
in native apps.

In the meantime I figured a less ugly workaround: we can implement GTK+
keybindings in GtkNSView for the most "popular" things like copy and paste,
and then simply call the embedded view's APIs directly. Not good, but better
than my idea above.
Comment 4 Michael Natterer 2013-07-23 04:42:28 UTC
Back from vacation. Will implement the "common default" actions (cut, copy,
paste, select all) as widget keybindings. If any more are needed or if a
better idea came up, please let me know.
Comment 5 Mikayla Hutchinson [MSFT] 2013-07-23 11:35:38 UTC
Can't you send the interpretKeyEvents message to the view?
Comment 6 Michael Natterer 2013-07-26 08:53:34 UTC
Created attachment 4450 [details]
This implements cut, copy, paste and select all

Yes this is very ugly, and not even done using the promised
bindings, but it works :)

Please test and let me know if anything is missing, it's
trivial to add.

Will roll a new patch set the day before GUADEC next week,
so you get all patches done until then.
Comment 7 Mikayla Hutchinson [MSFT] 2013-07-29 16:10:35 UTC
Patch landed, thanks!

Alan, could you verify it works?
Comment 8 Alan McGovern 2015-01-13 15:18:05 UTC
*** Bug 20732 has been marked as a duplicate of this bug. ***
Comment 9 Alan McGovern 2015-01-13 15:18:52 UTC
Reopening as bug #20732 was just filed saying that this does not work.
Comment 10 Cody Russell 2015-01-14 16:14:49 UTC
Fixed in mono/bockbuild master 299665380d350633c2b36f205eb50972f2a62d48