Text background color

Hello!

I know how to set a text view’s background color in IB ” there is an option for it.

I know how to set it programmatically ” that’s simple enough : myTextView’s setBackgroundColor_(myColor)

But is there a way to bind the color in IB? I didn’t find any, but maybe I missed something.

Regards,

I’m not sure any class supports binding color. But you can easily look this up yourself: the documentation lists what bindings each class supports.

The only class I found which can be bound by color is NSColorWell.

Not a very elegant solution, but placing a color well object right over the content view of a window does the trick.

If anybody has a better idea.

What is it that you’re trying to do? What’s wrong with changing it in code? What would you like to bind it to?

Ric

Ric,

The best comparison I found in docs for describe my app is a “Master-Detail Interface”.

Consider that the “nervous central system” of my application is a NSArrayController. There is a set of detailed objects (NSMutableDictionaries that I call “cards”) with keyed visual elements (texts, icon, sound and so on), arranged into the NSMutableArray of the controller.

The “current card”, visible in the editor, has its keyed properties bound to interface views. It corresponds to the current selection of the NSArrayController.

So far, I have avoided to set any of these properties by code. But one of these properties (of course I could leave it) is the background color of the card. I could set it by calling my gWindow’s or my gTextView’s background color method (as views don’t draw anything, they can’t set a color, unless I override the drawRect method, and I don’t know how to do that).

If I call these methods, from what handler shall I do it? some of a “on cardEntry_(aNotification)” ? or even worse, a “on goToCard (theID)” ?

Regards,

I can’t really say, since I still don’t understand the whole work flow of the app. Is there only one card visible at a time? Or, are there multiples, but only one is key? If you want the current card to have a different background color, it seems you should change the color when the card becomes the “current card”, however you make that happen.

Ric

Is it a way to join screen shots to the posts? If yes, we could save time.

There is one array:

1
4
7 /------------> property long text - bound to text view
18 ← this one is selected (the “key”) -------------> property icon - bound to an image well
56 ------------> property bkColor - bound to a color well
112

MODEL CONTROLLER VIEW

I told you my app was complex - but maybe I making it more complex that it should :wink:

Nevertheless, it’s now a lot LESS complex that it was one month ago. And therefore with cocoa there is a lot more efficient that my app 10 years ago.

But what does the user actually do to choose 18? What action does he take?

As the folder is open, the editor brings on the “first” card (in fact, the smallest ID) that he finds. From here the user has the choice

  1. to navigate with menu commands or buttons : first, previous, next, and last.
  2. to open a drawer and click in the list the card that he wants.

Both manners affect the selection of the controller. So there is no “go to card” in the code. As selection changes, the interface, bound to the array controller’s selection’s keys, automatically updates the different views: the current text in the text view, the icon in the image well, and so on. As the user edits the card, the NSMutableDictionary is updated as well.

So that’s easily handled with an action handler (or subclass the array controller if you prefer).

Presumable in a tale, in which case a delegate method can handle it.

Excuse me, Shane, what do you mean by “Presumable in a tale”?

Regards,

Sorry, table.