• 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: This has to be easy...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: This has to be easy...


  • Subject: Re: This has to be easy...
  • From: "Brian O'Brien" <email@hidden>
  • Date: Fri, 1 Apr 2005 14:50:05 -0700

Thank you so much for you answer Todd.
These thoughts have occurred to me as-well.
If I can't get the NSResponder working then this is what I will have to do.

When I created the controller last (as you suspected) it was defined as

@interface
MyController : NSObject

So I changed that to:

@interface
MyController : NSResponder

I added the mouse wheel event handler to the controller class:

- (void)scrollWheel:(NSEvent *)theEvent

I recompiled, but I didn't receive mouse wheel input. Is there more to it than that? Do I need
to register for these events in awakeFromNib or something?


On Apr 1, 2005, at 2:35 PM, Todd Yandell wrote:

Hi,

Only objects that inherit from NSResponder can receive mouse or key events. Normal classes that simply extend NSObject will not be able to receive any of the input events. Instead, I would just catch the event in each of the views, direct it to the controller class, and let the controller send it out individually to each view. For example:

ImageViewSubclass.m:

<x-tad-bigger>- (</x-tad-bigger><x-tad-bigger>void</x-tad-bigger><x-tad-bigger>)scrollWheel:(NSEvent *)event
{
[controller sendScrollEvents:event];
}

- (</x-tad-bigger><x-tad-bigger>void</x-tad-bigger><x-tad-bigger>)handleScrollWheel:(NSEvent *)event
{
</x-tad-bigger><x-tad-bigger>// Perform Scroll Action</x-tad-bigger><x-tad-bigger>
}</x-tad-bigger>


YourControllerClass.m:

<x-tad-bigger>- (</x-tad-bigger><x-tad-bigger>void</x-tad-bigger><x-tad-bigger>)sendScrollEvents:(NSEvent *)event
{
[view1 handleScrollWheel:event];
[view2 handleScrollWheel:event];
[view3 handleScrollWheel:event];
}</x-tad-bigger>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >This has to be easy... (From: "Brian O'Brien" <email@hidden>)

  • Prev by Date: Re: A Question about Bezier Paths..
  • Next by Date: Re: U3D File Format
  • Previous by thread: This has to be easy...
  • Next by thread: Re: This has to be easy...
  • Index(es):
    • Date
    • Thread