FROM : Brent Stace
DATE : Wed Oct 06 19:22:40 2004
I've had some grief over these panels in the last couple of days, so
any help would be appreciated.
My goal is: bind text color, document background color, and font
(size/name) of a certain NSTextView that in inside an NSWindow...Sounds
simple.
The behavior of the font panel seems to be different from one
application to the other...even within Apple applications. Case being
how the background and text color don't work in the terminal's window
settings (look at the font panel created from the display part of
window setting), but in TextEdit font panel they do. Not to mention,
both of these font panels are different from the default font panel
offered in cocoa. (Maybe these font panels use setAccessory:?)
anyhow....
As far as I see it I have two different possible implementations for
this.
Implementation 1:
Have a font panel for setting the NSTextView's font/size only and
ignore the fact that background color and text color don't work in that
font panel. Instead, offer two NSColorWells to the user so they can
edit those properties separate from the font panel. (Terminal's
behavior)
Snags:
- document background color is not a listed binding trait of NSTextView
in IB (but textcolor and font are). Is there some way to MAKE
background color a binding...maybe using the "bind:toObject:..."
method? if so, how?
- The changeColor method will be called for changing the color on
either the text color or background color NSColorWells. How can I tell
which one triggered it? (id) sender is the same regardless of which
called it (sender is the window). If I could tell which one triggered
it then I could write the correct information to the user defaults.
Implementation 2:
Include an instance of the font manager in my nib file, and have that
dictate all changes for the NSTextView. This uses the default value
(YES) for NSTextView's setUsesFontPanel: method. (TextEdit's behavior)
Snags:
- NSTextView has to be editable for this behavior to work, so I would
have to setEditable to YES or NO many times hopefully in the changeFont
or changeColor delegate methods since I want my NSTextView to be NOT
editable by the user.
- I am unable to get changeColor to run! - so this imeplementation has
become hard. I tried "[[NSColorPanel sharedColorPanel]
setDelegate:self]; [[NSFontManager sharedFontManager]
setDelegate:self];" but both don't seem to work. How, if possible, can
I get this to work?
- The NSTextView has to be in an NSWindow (not NSPanel), or else a
weird window leveling anomaly arises (if anyone cares).
- my last resort for this would be to save all font and color data when
the preference window closes...but then there is that editable trait of
the NSTextView I may have to ignore. Maybe NSTextView has a delegate
method I could override when it changes and I could tell it not to
change...I'm sure it's one of the 5 good looking delegate methods in
the super class (NSText) of NSTextView. I'm not sure how that code
would look though.
Which way would be the better implementation? It seems that
implementation 2 would be better, because everything is there in the
font panel, and there are no dead controls or wasted space, but it
seems hard to control and code. I couldn't find anything in the OSXHI
or the Apple SW Design Guidelines on which implementation is favored,
and since other Apple documentation lead me no where I'm now emailing
this list. It would be great if Apple could beef up their font panel
support.
Please help me! This program will be freeware ;-) Thank you!
------------------------
Brent Stace
DATE : Wed Oct 06 19:22:40 2004
I've had some grief over these panels in the last couple of days, so
any help would be appreciated.
My goal is: bind text color, document background color, and font
(size/name) of a certain NSTextView that in inside an NSWindow...Sounds
simple.
The behavior of the font panel seems to be different from one
application to the other...even within Apple applications. Case being
how the background and text color don't work in the terminal's window
settings (look at the font panel created from the display part of
window setting), but in TextEdit font panel they do. Not to mention,
both of these font panels are different from the default font panel
offered in cocoa. (Maybe these font panels use setAccessory:?)
anyhow....
As far as I see it I have two different possible implementations for
this.
Implementation 1:
Have a font panel for setting the NSTextView's font/size only and
ignore the fact that background color and text color don't work in that
font panel. Instead, offer two NSColorWells to the user so they can
edit those properties separate from the font panel. (Terminal's
behavior)
Snags:
- document background color is not a listed binding trait of NSTextView
in IB (but textcolor and font are). Is there some way to MAKE
background color a binding...maybe using the "bind:toObject:..."
method? if so, how?
- The changeColor method will be called for changing the color on
either the text color or background color NSColorWells. How can I tell
which one triggered it? (id) sender is the same regardless of which
called it (sender is the window). If I could tell which one triggered
it then I could write the correct information to the user defaults.
Implementation 2:
Include an instance of the font manager in my nib file, and have that
dictate all changes for the NSTextView. This uses the default value
(YES) for NSTextView's setUsesFontPanel: method. (TextEdit's behavior)
Snags:
- NSTextView has to be editable for this behavior to work, so I would
have to setEditable to YES or NO many times hopefully in the changeFont
or changeColor delegate methods since I want my NSTextView to be NOT
editable by the user.
- I am unable to get changeColor to run! - so this imeplementation has
become hard. I tried "[[NSColorPanel sharedColorPanel]
setDelegate:self]; [[NSFontManager sharedFontManager]
setDelegate:self];" but both don't seem to work. How, if possible, can
I get this to work?
- The NSTextView has to be in an NSWindow (not NSPanel), or else a
weird window leveling anomaly arises (if anyone cares).
- my last resort for this would be to save all font and color data when
the preference window closes...but then there is that editable trait of
the NSTextView I may have to ignore. Maybe NSTextView has a delegate
method I could override when it changes and I could tell it not to
change...I'm sure it's one of the 5 good looking delegate methods in
the super class (NSText) of NSTextView. I'm not sure how that code
would look though.
Which way would be the better implementation? It seems that
implementation 2 would be better, because everything is there in the
font panel, and there are no dead controls or wasted space, but it
seems hard to control and code. I couldn't find anything in the OSXHI
or the Apple SW Design Guidelines on which implementation is favored,
and since other Apple documentation lead me no where I'm now emailing
this list. It would be great if Apple could beef up their font panel
support.
Please help me! This program will be freeware ;-) Thank you!
------------------------
Brent Stace
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

