On Sep 2, 2008, at 1:59 PM, Stéphane Sudre wrote:

I have some code that works OK on Tiger but does not on Leopard.

I have a NSTableView with a column whose data cell is a NSButtonCell subclass.

The NSButtonCell is set to be a checkbox/switchbox.

The subclass implements the following method:

- (BOOL) trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag
{
        return YES;
}

in order to prevent clicks to be taken into account.


On Mac OS X 10.4.x, this works perfectly: you can't click the checkbox to change its value but you can initiate a drag by clicking on the checkbox.

On Mac OS X 10.5.x, this prevents the click but does not allow the drag operation to begin.


I've tried to play with the new NSTableViews methods in Leopard to deal with advanced tracking but this did not help. Either it's a regression or I'm not doing something correctly (I just hope it's the second case).


What could be done to make this work on Leopard?

The release notes should have covered this, but you want to implement this in 10.5 (only required if you are linking against 10.5 or higher):

enum {
    // An empty area, or did not hit in the cell
    NSCellHitNone = 0,
    // A content area in the cell
    NSCellHitContentArea = 1 << 0,
    // An editable text area of the cell
    NSCellHitEditableTextArea = 1 << 1,
    // A trackable area in the cell
    NSCellHitTrackableArea = 1 << 2,
};

@interface NSCell(NSCellHitTest)
/* Return hit testing information for the cell. Use a bit-wise mask to look for a specific value when calling the method. Generally, this should be overridden by custom NSCell subclasses to return the correct result. Currently, it is called by some multi-cell views, such as NSTableView.

    By default, NSCell will look at the cell type and do the following:

    NSImageCellType:
If the image exists, and the event point is in the image return NSCellHitContentArea, else NSCellHitNone.

    NSTextCellType (also applies to NSTextFieldCell):
        If there is text:
If the event point hits in the text, return NSCellHitContentArea. Additionally, if the cell is enabled return NSCellHitContentArea | NSCellHitEditableTextArea.
        If there is not text:
            Returns NSCellHitNone.

NSNullCellType (this is the default that applies to non text or image cells who don't override hitTestForEvent:):
        Return NSCellHitContentArea by default.
If the cell not disabled, and it would track, return NSCellHitContentArea | NSCellHitTrackableArea.
*/
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect) cellFrame ofView:(NSView *)controlView;
@end


Return anything except trackable. This fix it?

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 [EMAIL PROTECTED]

Reply via email to