Question

  • I would like to have something similar to the "List mode" of the stacks in the Dock. But it should have the behavior of NSPopUpButton, in terms of displaying the selected object still, when the "drawer" is collapsed. Each row should contain an image and to text columns.

    How would you realize this? Maybe subclassing NSPopUpButton, to display a CollectionView? Or having an ordanary button and attaching a window containing a CollectionView to it, when clicked?

  • Oh and this up and down bars, instead of scrollbars on the side - how's that done?

Was it helpful?

Solution

Why not use a regular NSPopUpButton whose menu assembly is replaced with subclassed NSMenu/NSMenuItem that draws things the way you want? You get all the scrolling behavior for free.

If you insist on using NSCollectionView, however:

1 - Don't subclass NSPopUpButton if you're planning on popping up anything other than a menu. It's built to display a menu. Just use a regular NSButton and manage its -state (NSOnState while the collection view is displayed; NSOffState otherwise) manually.

2 - You could show a borderless transparent window (many examples available online) with a standard collection view / scroll view assembly minus the scroll bars. The borderless window could host the up/down areas (which can be simple views with NSTrackingAreas to detect mouse over). These areas could manually scroll the NSScrollView a bit every n milliseconds using an NSTimer while hovered.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top