• 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: NSCollectionView item selection on Snow Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCollectionView item selection on Snow Leopard


  • Subject: Re: NSCollectionView item selection on Snow Leopard
  • From: Markus Spoettl <email@hidden>
  • Date: Mon, 31 Aug 2009 20:49:30 +0200

Hello Kevin,

I'm not observing the selection indexes of the collection view, but those of the bound NSArrayController.

I've followed your advice and overwrote both -scrollRectToVisible and - setSelectionIndexes: with breakpoints in them. In the case of the scrolling on -mouseDown: within an item, both are called - these are the call stacks:

-scrollRectToVisible:

#0 0x00087819 in -[ActivityCollectionView scrollRectToVisible:] at ActivityCollectionView.m:117
#1 0x9508797a in -[NSCollectionView _scrollToVisibleItemAtIndex:]
#2 0x950894d5 in -[NSCollectionView observeValueForKeyPath:ofObject:change:context:]
#3 0x9633d294 in NSKeyValueNotifyObserver
#4 0x9633cd33 in NSKeyValueDidChange
#5 0x9632175c in -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:]
#6 0x94952f00 in -[NSWindow makeFirstResponder:]
#7 0x94a6fe89 in -[NSWindow sendEvent:]
#8 0x94988bef in -[NSApplication sendEvent:]
#9 0x9491c65b in -[NSApplication run]
#10 0x94914695 in NSApplicationMain
#11 0x00006de1 in main at main.m:13


-setSelectionIndexes:

#0 0x00087877 in -[ActivityCollectionView setSelectionIndexes:] at ActivityCollectionView.m:122
#1 0x9508cfff in -[NSCollectionView mouseDown:]
#2 0x94985e9d in forwardMethod
#3 0x94a6ffc8 in -[NSWindow sendEvent:]
#4 0x94988bef in -[NSApplication sendEvent:]
#5 0x9491c65b in -[NSApplication run]
#6 0x94914695 in NSApplicationMain
#7 0x00006de1 in main at main.m:13


I disabled all custom code in my custom NSCollectionView to rule out any bad interaction with the framework. I also removed all mouse event methods in my custom item view.

The only strange thing I noticed is this (I've since removed the mouse handlers to make sure this isn't causing the problem). I roll my own selection decision rather than using the collection view's inherited behavior because my collection item view has a transparent border where a click should not make it first responder:

- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint pt = [self convertPoint:[theEvent locationInWindow] fromView:nil];


    NSRect visibleRect = [self visibleViewBounds];

if (NSPointInRect(pt, visibleRect)) {
if (!selected) {
[controller setSelected:YES]; // let the item's controller know
// we need to be selected
}
}
}


What I've noticed is that for rows where the strange auto-scrolling happens, pt.y is negative, even though the clicked point lies well within the view that was clicked. It is correct for the upper rows, where the selection works normally.

This indicates to me (maybe wrongly so) that NSCollectionView does some stuff behind my back with the coordinate system and it fails to convert the coordinates properly.

I thought I mention this because it's the only observation I can offer that might be useful.

Also, I'm compiling on 10.6 with the base SDK set to 10.5, in case that matters (it probably does).

Let me know if you need any more information, I can also provide you with a debug-compiled version of the app if that helps.

Regards
Markus

On Aug 31, 2009, at 7:07 PM, Kevin Perry wrote:

Markus,

I just tried running the IconCollection sample app and did not observe the problems you are seeing. Have you subclassed NSCollectionView in any way? Are you, perhaps, observing - selectionIndexes and calling a method on the NSCollectionView that causes the scrolling you see? KVO notifications for - [NSCollectionView selectionIndexes] for mouse selections did not always work correctly in Leopard, but they do now in Snow Leopard.

Try breaking in the debugger on -scrollRectToVisible or - [NSCollectionView setSelectionIndexes:] and you may discover what is causing these problems.

-kp

From: Markus Spoettl <email@hidden>
Date: August 31, 2009 7:34:07 AM PDT
To: CocoaDev list <email@hidden>
Subject: NSCollectionView item selection on Snow Leopard

Hello,

I have an NSCollectionView that used to work normally on Leopard, when the App is running on Snow Leopard, item selection using the mouse by clicking on it doesn't work correctly.

When clicking on an item in the bottom-most visible row, instead of selecting that item the collection view scrolls down a row (unless there is no item visible lower than the item that is clicked on).

Does anyone else see this issue?

Regards
Markus
--
__________________________________________
Markus Spoettl



-- __________________________________________ Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSCollectionView item selection on Snow Leopard
      • From: Markus Spoettl <email@hidden>
References: 
 >NSCollectionView item selection on Snow Leopard (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Re: 10.6: Check Box Cells in NSTableViews always editable!
  • Next by Date: Re: Why would NSViewController loadView fail?
  • Previous by thread: NSCollectionView item selection on Snow Leopard
  • Next by thread: Re: NSCollectionView item selection on Snow Leopard
  • Index(es):
    • Date
    • Thread