Forum Xamarin.Mac

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

(Mis)using NSTextView to get a proper key interpretation?

Hi,

I'm working on a Terminal App and I already have a working version using Qml.Net and .NET Core.
Now I'm trying to port the current state to Xamarin.Forms as I think this will overall fit better with what I plan to do.

I realized that Xamarin.Forms doesn't have any low level Key input interaction and the suggested way of handling this seems to be to intercept keys in the platform specific part of the Xamarin.Forms application and pass it to the platform independent part.

This brings me to Xamarin.Mac as this is the first platform specific part I want to port to.

Qt has some Key abstraction that is a little bit above the raw Key inputs. It already contains pre-edit states of the input device (or marked state) that gets active if you build characters using multiple keys (like â).

The question now is: How do I get that level of preprocessing in Xamarin.Mac without having something from AppKit directly part of the Window? Is it possible to instantiate e.g. a NSTextView, pass it all the key events and get the preprocessed key / text events from that?
Has anyone a better idea to solve the problem I mentioned?

I don't plant to support all the different keyboard layout and language specific input behaviours explicitly especially when there is already something "in reach" that does all that already.

Thanks for your answers!

Best Answer

  • MichaelLamersMichaelLamers USMember
    Accepted Answer

    I found a solution to this problem.

    I created a KeyHandlingContentView derived from ContentView in Xamarin.Forms and a custom Renderer for Mac that implements INSTextInputClient.

    This way the key events can be passed from that custom renderer to the Xamarin.Forms control.

Answers

  • MichaelLamersMichaelLamers USMember
    Accepted Answer

    I found a solution to this problem.

    I created a KeyHandlingContentView derived from ContentView in Xamarin.Forms and a custom Renderer for Mac that implements INSTextInputClient.

    This way the key events can be passed from that custom renderer to the Xamarin.Forms control.

Sign In or Register to comment.