 |
 |
Does NSToolbarShowColorsItemIdentifier send a method?
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2005
Status:
Offline
|
|
I know that NSToolbarPrintItemIdentifier sends printDocument: to firstResponder, but I can't find information on how to use NSToolbarShowColorsItemIdentifier. I guess I might not be able to do what I want with it, which is to have the result the color panel sends back change the color of the text in a non-editable NSTextField.
|
YummySoup! - Recipe management and sharing at its best!
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2005
Status:
Offline
|
|
OK, I have created a method to change the text of the NSTextField, that method being:
Code:
- (void)changeTextColor:(NSColor *)sender
I have setup a collorWell and set its action to changeTextColor: and it works perfectly. Now what I would like to do is remove that colorWell and have my NSToolbarShowColorsItemIdentifier take the colorWells place. I have in place this code, which doesn't work:
Code:
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)willBeInserted
{
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
if ([itemIdentifier isEqual: NSToolbarShowColorsItemIdentifier]) {
NSLog(@"NSToolbarShowColorsItemIdentifier phrased");
[item setTarget:self];
[item setAction:@selector(changeTextColor:)];
}
return [item autorelease];
}
I was hoping that someone could help me figure out how to get the toolbar item to plug into the method for changing the text color I created. Thanks!
(Last edited by HungrySeacow; Mar 17, 2006 at 11:59 PM.
)
|
YummySoup! - Recipe management and sharing at its best!
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
I think what NSToolbarShowColorsItemIdentifier does (or rather, what the NSToolbarItem with that as its identifier does) is show the shared color panel. If that's the case (though I admit I haven't tested it), you can probably implement -(void)changeColor:(id)sender on an object in the responder chain or set the color panel's action and target.
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2005
Status:
Offline
|
|
Well I figured it out. I had to modify NSToolbarShowColorsItemIdentifier with the method, - (void) toolbarWillAddItem  NSNotification *)notification. Here is my code if anyone is interested:
Code:
- (void) toolbarWillAddItem:(NSNotification *)notification
{
NSToolbarItem *addedItem = [[notification userInfo] objectForKey: @"item"];
if([[addedItem itemIdentifier] isEqual: NSToolbarShowColorsItemIdentifier]) {
[addedItem setToolTip:@"Change Text Color"];
[addedItem setTarget:self];
[addedItem setAction:@selector(showColorPicker)];
}
}
- (void)showColorPicker
{
NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];
[colorPanel setTarget:self];
[colorPanel setAction:@selector(changeTextColor:)];
[NSApp orderFrontColorPanel:self];
}
- (void)changeTextColor:(id)sender
{
NSColor *colorFromWell = [sender color];
[textField1 setTextColor:colorFromWell];
[textField2 setTextColor:colorFromWell];
}
|
YummySoup! - Recipe management and sharing at its best!
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Well, I'm glad you got it sorted!
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |