Table view interface question

(Andreas Kiel) #1

Thanks to Shane and Mark I do see a some light on the horizon with my little test app.
As I explained before in other questions the app somehow should process video subtitle files.
The nature of these cue text things is that the text is displayed against a black (or grey) background. Text color default is white, but yellow, cyan sometimes purple are used as well depending on the type of cues.
So the background of the table view is black, some text cells might have a dark color other than black.
As long as no row is selected everything is fine. Once a row is selected it will get blue ( or the settings of the system). That’s something people might be able to live with.
But when the table view is “out of focus” the row turns into “light grey” and everything is not readable anymore.
Same with text selection.

Is there a way to change the “high-lighting” of a row into something like a “focus ring”?

or get another color like a dark grey

(Shane Stanley) #2

You probably need to do something like set the selectionHighlightStyle property to NSTableViewSelectionHighlightStyleNone, and then subclass table view or row view and implement your own highlighting.

(Andreas Kiel) #3

Thanks Shane!

Unfortunately I have no idea (yet) how to do that.
But I found a poor man’s solution. I set the “Highlight” to “Source List” and put some vertical offset to the text cells.

(Shane Stanley) #4

One of the suggestions I found most useful when starting with Xcode was to always look for examples of what I wanted. If I couldn’t find them, there’s a fair chance I was doing something either impossible or discouraged (“fighting the frameworks”). It’s not always the case, but it’s worth considering. How many all-dark-background tables do you see?

That said, you may do better to make a single-column view-based table. That way you put all info as text fields on a view, and it gives you a lot more flexibility in terms of layout.

(Andreas Kiel) #5


Thanks for sharing your thoughts.

In my business I haven’t seen many ‘not all-dark-background’ tables.

Unfortunately a single column table would not make any sense at all in this case. Current column set is the minimum. The values displayed makes it hard to understand though.

(Shane Stanley) #6

In case you missed what I was saying, it would still contain the same info. Think of each cell being like a small window that can contain many fields, arranged as you like.

(Andreas Kiel) #7

Sorry I missed that.

Are there any examples you know of. Never did that before.

(Shane Stanley) #8

Most tables are view-based these days. From simple things like, say, the search column in Xcode, to the columns in FaceTime, the second panel in Mail, the sidebar in Messages…

Here’s a link to an Apple sample project:

(Andreas Kiel) #9

I was thinking of a simple example :wink:

(Andreas Kiel) #10

Shane, what it would cost me to write a simple sample code for a table like shown above?

(Shane Stanley) #11

Depending on your requirements, it’s really not that hard. How are you populating your table – bindings? And how many of your current columns are editable?

(Andreas Kiel) #12

I use bindings to populate the table view.
Finally none of the columns need to be edited directly.
One problem I do see though is to edit the values and send back to the array.

Here is a more understandable screen shot.

The upper black region displays the “real” text. The text in the table might be wrapped. Means you have a long text line and it looks good in the table cell cause it is wrapped but would be too long in real life usage. This is a “text view” to have a coloured insertion point.
The values per row are times for the text: in, out, duration and distance in frames to the previous text cue. The text itself followed by the count of characters of the longest line of the text and the reading speed in “characters per second”.

So changing the text will/can change both the “max characters” and/or the “CPS” value.
I haven’t found a way yet to update values automatically or get a warning when the row changes.
It worked fine in ASS to compare row changes before switching to the next row.
I could use a text field, but only get a black insertion point.
Changing times will affect “CPS” as well but can handled easily I think.

(Shane Stanley) #13

OK, that makes it simpler. So instead of binding columns to the array controller, you bind the table itself. The bindings look like this:

If you expand the table hierarchy for a single-column table, it looks like this:


The highlighted item is a view (NSTableCellView) which you can actually drag out to make as big as you want, and you can add text fields, image views, etc to it. By default is has just one text field, confusingly labeled Table View Cell in the above.

Once you have added the views you want, you set up their bindings. So the binding for standard text field might look like this:


It always starts with objectValue., and you add the key for the particular item you want inserted.

(You can ignore the Text Cell item — that’s for cell-based tables only.)

(Andreas Kiel) #14


Populating the table works like a charm. And looks much better.

But now I got the problem that I can’t set any other interface object using bindings to the selected row values.

(Shane Stanley) #15

That sounds like you didn’t set the Selection Indexes binding above.

(Andreas Kiel) #16

My fault.
Didn’t see that the first screen shot can be expanded.
Too ho here.