Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: determining keyboard layout?




On Sep 12, 2006, at 3:10 AM, Elliott Hughes wrote:

i don't care if i have to use Cocoa or Carbon (though obviously pure Java would be ideal), but is there any way i can tell what keyboard layout is in use? a Danish user reckons that the command-shift [ and command-shift ] work-around for not being able to specify command-{ and command-} in Java doesn't work on a Danish keyboard, where you get { and } from alt-shift 8 and alt-shift 9.

rather than use un-Mac keyboard equivalents for everyone, i was thinking of detecting "non English" keyboard layouts and using an alternative there. only i can't work out how to do the detection.

You can ask the InputContext of a component for its locale. We return the ISO language/country/variant for the currently selected keyboard layout.

(if anyone knows how to get command-shift [ and command-shift ] to work on a Danish keyboard, that would be better still.)

The problem here is that the DefaultKeyTypedAction in the DefaultEditorKit blocks key-typed events with the META (Command) key bit set. We had to change the logic in javax.swing.text.DefaultEditorKit, because a key-typed event with the ALT key was being blocked. On the Mac, option-whatever always generates a valid key, so many non-ASCII values that could be generated on a Mac keyboard would be lost. We changed it to look for META, since command-whatever typically invokes a menu equivalent and we don't want them to go to the text component... except in this case.

I'm not sure right now what a good workaround for this would be. One possibility would be to somehow intercept the key-typed and turn off the META flag before the text component processed it.

Scott
------------------
Scott Kovatch
Apple Computer
Java Runtime Classes
Cleveland Hts, OH
email@hidden

I am Scott Kovatch, and I approved this message.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >determining keyboard layout? (From: Elliott Hughes <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.