• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: The current keyboard icon?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The current keyboard icon?


  • Subject: Re: The current keyboard icon?
  • From: "Martin" <email@hidden>
  • Date: Tue, 04 May 2004 15:28:38 -0700

Hey guys,

To get the current keyboard layout:

OSStatus osErr;
KeyboardLayoutRef keyRef;

osErr = KLGetCurrentKeyboardLayout( &keyRef );


Once you have a keyboard reference, you can get get the icon reference:

IconRef icon;
osErr = KLGetKeyboardLayoutProperty( keyRef, kKLIcon, (void*)(&icon) );


And finally convert it to an NSImage:

IconFamilyHandle fam;
NSData* imgData;
NSImage* img;

osErr = IconRefToIconFamily( icon, kSelectorAllAvailableData, &fam );
imgData = [NSData dataWithBytes:*fam length:GetHandleSize((Handle)fam)];
img = [[NSImage alloc] initWithData:imgData];

Hope this helps,

~Martin


On May 04 2004, Ondra Cada <email@hidden> wrote:

>happens anybody to know how to obtain the icon of the currently
>selected keybaord?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: The current keyboard icon?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Using Alert Sheets for multiple methods
  • Next by Date: Re: setHidden: on MacOS 10.2
  • Previous by thread: Re: The current keyboard icon?
  • Next by thread: Re: The current keyboard icon?
  • Index(es):
    • Date
    • Thread