• 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: How to make NSImageView respond to keyboard events?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make NSImageView respond to keyboard events?


  • Subject: Re: How to make NSImageView respond to keyboard events?
  • From: matt neuburg <email@hidden>
  • Date: Sat, 15 May 2004 15:21:26 -0700

On 5/15/04 at roughly 2:44 PM, thus spake M. Uli Kusterer
<email@hidden>:

>At 12:52 Uhr -0700 15.05.2004, matt neuburg wrote:
>> >- Create a new Cocoa Application in XCode,
>>>- Open MainMenu.nib in Interface Builder,
>>>- Subclass NSImageView -> MyImageView,
>>>- Put an NSImageView on the window,
>> >- Set the Custom Class of this NSImageView to MyImageView,
>>>- Set the initialFirstResponder of the Window to the image view (whose
>>>class is now MyImageView)
>>>- Create the files for MyImageView,
>>>- Back in XCode, I add this to the implementation file:
>>>
>>>- (void)keyDown:(NSEvent *)theEvent
>>>{
>>> NSLog (@"Hi!");
>>>}
>>>- Build & Run the app
>> >When I hit a key (any key), I only get a beep.
>
>Wouldn't you also need to override acceptsFirstResponder: or whatever
>it's called to return YES so AppKit knows this view may have the
>keyboard focus?
>
>And maybe Matt has the OS set to also allow focussing on buttons or
>something similar? I would guess that that may cause a difference in
>behavior.

Well spotted, Uli! Yes, I was able to get the "beep" by turning off "full
keyboard access". And so I discovered that in that situation, it is actually
needsPanelToBecomeKey that Laurent needs to override.

So, that solves Laurent's problem and also explains the difference in our
results. m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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.


References: 
 >Re: How to make NSImageView respond to keyboard events? (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: Re: IBAction in a different class
  • Next by Date: Re: Bringing app to front
  • Previous by thread: Re: How to make NSImageView respond to keyboard events?
  • Next by thread: Re: How to make NSImageView respond to keyboard events?
  • Index(es):
    • Date
    • Thread