Re: Stop NSScrollView from catching scroll events.

2009-03-24 Thread Michael Ash
On Tue, Mar 24, 2009 at 1:12 AM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Mon, Mar 23, 2009 at 10:48 PM, Michael Ash michael@gmail.com wrote:
 Right, that would be my preferred way of doing it. I like to use the
 NSObject methods rather than the ObjC runtime functions where I can,
 since the NSObject methods are usually friendlier and more broadly
 compatible.

 For the record, I agree with Mike on this point; had I remembered the
 method, I would have used it too.  I happened to be in the ObjC
 runtime docs looking up the signature for method_getImplementation, so
 I went with the runtime function.

 The advantage of using +instanceMethodForSelector: is that classes can
 override it to seamlessly provide forwarded method implementations,
 for example to a delegate.

Actually, message forwarding using -forwardInvocation: or
-forwardingTargetForSelector: will still work either way. Both the
ObjC runtime function and this method will return a pointer to the
Magical Forwarding Trampoline which objc_msgSend() uses to do
forwarding, so you get the same results either way.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Stop NSScrollView from catching scroll events.

2009-03-23 Thread Ben Lachman
I have a tableview that's neatly wrapped in a scroll view by IB.  I  
manually resize the scrollview whenever a row is added to the  
tableview so that all the row are always visible.  Thus I basically  
don't need a scroll view.  However even though it can't actually  
scroll the tableview it still eats scroll events when the mouse is  
over it.  I tried ripping the tableview out of the scroll view  
programatically, but that didn't yield useable results.  Is there a  
straight forward way to have a scroll view pass scroll events on up  
the responder chain?


Thanks,
-Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stop NSScrollView from catching scroll events.

2009-03-23 Thread Michael Ash
On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote:
 I have a tableview that's neatly wrapped in a scroll view by IB.  I manually
 resize the scrollview whenever a row is added to the tableview so that all
 the row are always visible.  Thus I basically don't need a scroll view.
  However even though it can't actually scroll the tableview it still eats
 scroll events when the mouse is over it.  I tried ripping the tableview out
 of the scroll view programatically, but that didn't yield useable results.
  Is there a straight forward way to have a scroll view pass scroll events on
 up the responder chain?

Just subclass NSScrollView, and override -scrollWheel: to call
directly through to NSResponder's implementation and bypass
NSScrollView's implementation.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stop NSScrollView from catching scroll events.

2009-03-23 Thread Ben Lachman

On Mar 23, 2009, at 10:54 AM, Michael Ash wrote:


On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote:
I have a tableview that's neatly wrapped in a scroll view by IB.  I  
manually
resize the scrollview whenever a row is added to the tableview so  
that all
the row are always visible.  Thus I basically don't need a scroll  
view.
 However even though it can't actually scroll the tableview it  
still eats
scroll events when the mouse is over it.  I tried ripping the  
tableview out
of the scroll view programatically, but that didn't yield useable  
results.
 Is there a straight forward way to have a scroll view pass scroll  
events on

up the responder chain?


Just subclass NSScrollView, and override -scrollWheel: to call
directly through to NSResponder's implementation and bypass
NSScrollView's implementation.


I was thinking this was easy, but now I'm not so sure.

How do you call through to some arbitrary class in a class's  
inheritance chain?


Thanks,
-Ben
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stop NSScrollView from catching scroll events.

2009-03-23 Thread Kyle Sluder
On Mon, Mar 23, 2009 at 5:35 PM, Ben Lachman blach...@mac.com wrote:
 How do you call through to some arbitrary class in a class's inheritance
 chain?

Typically, you don't.  Just hand it off to super.  NSView isn't
declared to implement -scrollWheel:.

If you *really* need to invoke a specific class's implementation of a
method, use class_getInstanceMethod to get the method's
implementation, and then just invoke that implementation:

// Warning: written in mail client, YMMV etc.
- (void)scrollWheel:(NSEvent *)theEvent
{
  Method theMethod = class_getMethod([NSResponder class],
@selector(scrollWheel:));
  IMP theImpl = method_getImplementation(theMethod);
  (void (*) (id, SEL, NSEvent*))(theImpl)(self,
@selector(scrollWheel:), theEvent);
}

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stop NSScrollView from catching scroll events.

2009-03-23 Thread Corbin Dunn


On Mar 23, 2009, at 2:35 PM, Ben Lachman wrote:


On Mar 23, 2009, at 10:54 AM, Michael Ash wrote:

On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com  
wrote:
I have a tableview that's neatly wrapped in a scroll view by IB.   
I manually
resize the scrollview whenever a row is added to the tableview so  
that all
the row are always visible.  Thus I basically don't need a scroll  
view.
However even though it can't actually scroll the tableview it  
still eats
scroll events when the mouse is over it.  I tried ripping the  
tableview out
of the scroll view programatically, but that didn't yield useable  
results.
Is there a straight forward way to have a scroll view pass scroll  
events on

up the responder chain?


Just subclass NSScrollView, and override -scrollWheel: to call
directly through to NSResponder's implementation and bypass
NSScrollView's implementation.


I was thinking this was easy, but now I'm not so sure.

How do you call through to some arbitrary class in a class's  
inheritance chain?


It's definitely the way to do it.

Just send it on to [self nextResponder]. that's all!

corbin


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stop NSScrollView from catching scroll events.

2009-03-23 Thread Ben Lachman

On Mar 23, 2009, at 5:47 PM, Corbin Dunn wrote:


On Mar 23, 2009, at 2:35 PM, Ben Lachman wrote:


On Mar 23, 2009, at 10:54 AM, Michael Ash wrote:

On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com  
wrote:
I have a tableview that's neatly wrapped in a scroll view by IB.   
I manually
resize the scrollview whenever a row is added to the tableview so  
that all
the row are always visible.  Thus I basically don't need a scroll  
view.
However even though it can't actually scroll the tableview it  
still eats
scroll events when the mouse is over it.  I tried ripping the  
tableview out
of the scroll view programatically, but that didn't yield useable  
results.
Is there a straight forward way to have a scroll view pass scroll  
events on

up the responder chain?


Just subclass NSScrollView, and override -scrollWheel: to call
directly through to NSResponder's implementation and bypass
NSScrollView's implementation.


I was thinking this was easy, but now I'm not so sure.

How do you call through to some arbitrary class in a class's  
inheritance chain?


It's definitely the way to do it.

Just send it on to [self nextResponder]. that's all!


Ah! Thanks Corbin.  Thats the right (and easy) way to do it.

For the record, this works too (and supports tiger, I'm not sure if  
Kyle's code does):


- (void)scrollWheel:(NSEvent *)theEvent {
void (*responderScroll)(id, SEL, id);

	responderScroll = (void (*)(id, SEL, id))([NSResponder  
instanceMethodForSelector:@selector(scrollWheel:)]);


responderScroll(self, @selector(scrollWheel:), theEvent);
}

Cheers,
-Ben
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stop NSScrollView from catching scroll events.

2009-03-23 Thread Michael Ash
On Mon, Mar 23, 2009 at 6:09 PM, Ben Lachman blach...@mac.com wrote:
 On Mar 23, 2009, at 5:47 PM, Corbin Dunn wrote:

 On Mar 23, 2009, at 2:35 PM, Ben Lachman wrote:

 On Mar 23, 2009, at 10:54 AM, Michael Ash wrote:

 On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote:

 I have a tableview that's neatly wrapped in a scroll view by IB.  I
 manually
 resize the scrollview whenever a row is added to the tableview so that
 all
 the row are always visible.  Thus I basically don't need a scroll view.
 However even though it can't actually scroll the tableview it still
 eats
 scroll events when the mouse is over it.  I tried ripping the tableview
 out
 of the scroll view programatically, but that didn't yield useable
 results.
 Is there a straight forward way to have a scroll view pass scroll
 events on
 up the responder chain?

 Just subclass NSScrollView, and override -scrollWheel: to call
 directly through to NSResponder's implementation and bypass
 NSScrollView's implementation.

 I was thinking this was easy, but now I'm not so sure.

 How do you call through to some arbitrary class in a class's inheritance
 chain?

 It's definitely the way to do it.

 Just send it on to [self nextResponder]. that's all!

 Ah! Thanks Corbin.  Thats the right (and easy) way to do it.

 For the record, this works too (and supports tiger, I'm not sure if Kyle's
 code does):

 - (void)scrollWheel:(NSEvent *)theEvent {
        void (*responderScroll)(id, SEL, id);

        responderScroll = (void (*)(id, SEL, id))([NSResponder
 instanceMethodForSelector:@selector(scrollWheel:)]);

        responderScroll(self, @selector(scrollWheel:), theEvent);
 }

Right, that would be my preferred way of doing it. I like to use the
NSObject methods rather than the ObjC runtime functions where I can,
since the NSObject methods are usually friendlier and more broadly
compatible.

As to the question of doing this versus simply manually sending the
message to the next responder, it's really just a question of
preference here. I like letting the existing code handle things, but
since this particular method is so simple, and its documentation
precisely states what it does, it really makes no difference here. For
something where the super-superclass does something more complex, this
technique would have a significant advantage.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Stop NSScrollView from catching scroll events.

2009-03-23 Thread Kyle Sluder
On Mon, Mar 23, 2009 at 10:48 PM, Michael Ash michael@gmail.com wrote:
 Right, that would be my preferred way of doing it. I like to use the
 NSObject methods rather than the ObjC runtime functions where I can,
 since the NSObject methods are usually friendlier and more broadly
 compatible.

For the record, I agree with Mike on this point; had I remembered the
method, I would have used it too.  I happened to be in the ObjC
runtime docs looking up the signature for method_getImplementation, so
I went with the runtime function.

The advantage of using +instanceMethodForSelector: is that classes can
override it to seamlessly provide forwarded method implementations,
for example to a delegate.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com