MonoDevelop.Components.Commands.CommandManager.OnNSEventKeyPress C# (CSharp) Method

OnNSEventKeyPress() private method

private OnNSEventKeyPress ( AppKit ev ) : AppKit.NSEvent
ev AppKit
return AppKit.NSEvent
		AppKit.NSEvent OnNSEventKeyPress (AppKit.NSEvent ev)
		{
			// If we have a native window that can handle this command, let it process
			// the keys itself and do not go through the command manager.
			// Events in Gtk windows do not pass through here except when they're done
			// in native NSViews. PerformKeyEquivalent for them will not return true,
			// so we're always going to fallback to the command manager for them.
			// If no window is focused, it's probably because a gtk window had focus
			// and the focus didn't go to any other window on close. (debug popup on hover
			// that gets closed on unhover). So if no keywindow is focused, events will
			// pass through here and let us use the command manager.
			var window = AppKit.NSApplication.SharedApplication.KeyWindow;
			if (window != null) {
				// Try the handler in the native window.
				if (window.PerformKeyEquivalent (ev))
					return null;

				// If the window is a gtk window and is registered in the command manager
				// process the events through the handler.
				var gtkWindow = MonoDevelop.Components.Mac.GtkMacInterop.GetGtkWindow (window);
				if (gtkWindow != null && !TopLevelWindowStack.Contains (gtkWindow))
					return null;
			}

			// If a modal dialog is running then the menus are disabled, even if the commands are not
			// See MDMenuItem::IsGloballyDisabled
			if (DesktopService.IsModalDialogRunning ()) {
				return ev;
			}

			var gdkev = MonoDevelop.Components.Mac.GtkMacInterop.ConvertKeyEvent (ev);
			if (gdkev != null) {
				if (ProcessKeyEvent (gdkev))
					return null;
			}
			return ev;
		}
		#endif