0

I am basically trying to recreate the popOver that exists in certain Xcode Settings, like this one in Build Settings:

enter image description here

I have tried both with and without using an NSArrayController to control the content but in each of the tests I ran in to different problems I haven't been able to solve.

Desired Result

  • Complete White Background
  • Multiple Selection and (Single) Editable Cells
  • No Reordering is required
  • When I press the + button I want the new cell to be selected and in edit mode
  • I want to get notification of when text changes while editing to be able to respond to that.

1. Using Delegate Methods.

When I had set up everything up I got this result:

enter image description here

That didn't look good, so I went and selected "Draws Background" for the NSTableViewCell, which resulted in this which looks nice when I edit a cell:

enter image description here enter image description here

But when i just Highlight the cell, it looks like this:

enter image description here

It looks like the highlighting get's placed behind the cell background.

Here I'm stuck and don't know how to fix.

2. Using NSArrayController

When I reconfigure and bind this to an NSArrayController the highlighting looks great:

enter image description here

But when I edit a cell, the entire background changes to grey:

enter image description here

This is also not what I want, but can't figure out what to do about.

--

Notes

In Desired Result I listed some things like "When I press the + button I want the new cell to be selected and in edit mode" and "I want to get notification of when text changes while editing to be able to respond to that." To possibly influence the choice of what route to take, as there are more things about thins TableView I haven't figured out.

But this question Is all about how to fix the highlighting and selection so they stay white all the time, and just selecting a cell looks as expected.

Example Code

Example code for the Delegates Method version:

https://github.com/erikberglund/StackOverflow/tree/master/TableViewDelegates

Example code for the Bindings version:

https://github.com/erikberglund/StackOverflow/tree/master/TableViewBindings

7
  • 1
    Please give a link to github sample. BTW turn on alternating rows for nstableview (checkbox)
    – Marek H
    Sep 4, 2015 at 18:25
  • Yes, about the alternating rows, that's about the only thing I would like to leave out and only use a white background. Sep 4, 2015 at 19:39
  • Your code is fine on 10.11.(15A279b) Or I didn't get the question postimg.org/gallery/16fmzog4o/ce73258f I did turn off alternating as you wanted
    – Marek H
    Sep 4, 2015 at 20:34
  • Yes, that certainly looks fine, and what I would like as well. So now I'm even more confused as to why I get the grey blocks I'm seeing. On your screenshots even the buttons have a white background, which would be my next question which I would tackle after this. As my understanding was that to change a button color you had to subclass it. I am using 6.4 (6E35b) and OS X 10.10.5 (14F27). But that seems weird to make a difference. Because if you look at my screenshots they are not equal to yours, and the code i posted looks the same as my screenshots. Sep 4, 2015 at 21:00
  • Try to turn on Core Animation layer on Xcode tab. But as I read in other post Core Animation is slow/buggy on 10.10 with many views. Another try might be cell based nstableview. Try to test it on freshly installed system (10.9,10.10,10.11) in VirtualBox.
    – Marek H
    Sep 4, 2015 at 21:11

1 Answer 1

3

Force the appearance to aqua. So instead of inherited select aqua. This solved the issues for me.

Aqua

5
  • Yes, this is a known bug in Yosemite with vibrancy and popovers. It's apparently fixed in El Capitan, but this is the workaround given out by Apple in the meantime. Sep 5, 2015 at 9:29
  • Also try to remove [super draw:dirtyrect] on your white background
    – Marek H
    Sep 5, 2015 at 9:36
  • Amazing! Thank you so much, this fixed the issue for me on 10.10.5. I also removed [super draw:dirtyRect] from the background and that seem to work as expected as well. I'm very grateful for you help! Sep 5, 2015 at 10:36
  • inherited(Aqua) was already set to Aqua so setting it to Aqua didnt do anything. Using High Sierra OS. Jan 22, 2018 at 3:21
  • Try white color subview and for tableview set transparent color
    – Marek H
    Jan 22, 2018 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.