문제

  • 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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top