Re: Transparant button click

2010-08-30 Thread Uli Kusterer
On Aug 27, 2010, at 10:18 PM, Erik Colson wrote:
> What would be the best way to create a button with a partially transparent 
> image on a nsview that would only respond to mouse clicks that are on the 
> non-transparent part of the image ?


 Override NSView's -hitTest: method on a subclass of NSButton and check the 
pixel clicked on the NSImage for transparency > 0.5 (or use 10.6's new image 
hit-testing method)?

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."

___

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: Transparant button click

2010-08-28 Thread Andreas Mayer

Am 28.08.2010 um 10:30 schrieb Graham Cox:

> This NSImage method is the only one built-in that offers this kind of 
> hit-test functionality (10.6 only). You could build your button around it. 
> But for earlier OS versions you have to do the hit-test yourself. This 
> involves testing the point against the alpha channel value of the image at 
> that point.

You can find sample code here:

http://www.harmless.de/cocoa-code.php

Look for the AMShapedButton project.

It's rather old but I just confirmed that it still builds. :)


Andreas___

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: Transparant button click

2010-08-28 Thread Graham Cox

On 27/08/2010, at 10:18 PM, Erik Colson wrote:

> Hi,
> 
> What would be the best way to create a button with a partially transparent 
> image on a nsview that would only respond to mouse clicks that are on the 
> non-transparent part of the image ?


This NSImage method is the only one built-in that offers this kind of hit-test 
functionality (10.6 only). You could build your button around it. But for 
earlier OS versions you have to do the hit-test yourself. This involves testing 
the point against the alpha channel value of the image at that point.

- 
(BOOL)hitTestRect:(NSRect)testRectDestSpacewithImageDestinationRect:(NSRect)imageRectDestSpacecontext:(NSGraphicsContext*)referenceContexthints:(NSDictionary
 *)hintsflipped:(BOOL)flipped

--Graham___

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


Transparant button click

2010-08-27 Thread Erik Colson
Hi,

What would be the best way to create a button with a partially transparent 
image on a nsview that would only respond to mouse clicks that are on the 
non-transparent part of the image ?

Thanks !
--
Erik Colson___

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