• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Toolbar problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toolbar problems


  • Subject: Re: Toolbar problems
  • From: j o a r <email@hidden>
  • Date: Thu, 10 Apr 2003 07:58:58 +0200

On Thursday, Apr 10, 2003, at 01:21 Europe/Stockholm, Yuhui wrote:

1. Toolbar doesn't seem to recognize Localizable.strings:
For each toolbar item, I set its label to "NSLocalizable(@"the item's label", @"")" and its tooltip to "NSLocalizable(@"the item's tooltip", @"")". But when I compiled and ran my program, the toolbar didn't get its values from Localizable.strings. To ensure that I wasn't seeing things, I changed one item's label to "Wacky" and another to "Fubar" and both didn't show up. In fact, the toolbar item used the first part of the NSLocalizable() function (e.g. "the item's label", "the item's tooltip") as its label and tooltip respectively.

I'm not using a dictionary for my toolbar, but after encountering this problem, I'm seriously thinking of switching over. But before I do, I want to know if I've encountered a known bug or not.

You probably wanted to write NSLocalizedString(@"SomeStringTag", @""), and not NSLocalizable()...

Also, when you have this kind of problems, try to log the results before sending them away:

NSString *lStr = NSLocalizedString(); // Create lStr
NSLog(lStr); // Check that lStr is good before...
// Do something with lStr

2. Toolbar can't access methods in objects that aren't linked to the toolbar's window/object.
E.g. my toolbar is in mainWindow. But I have a method in externalObject that I want to set a toolbar item to use as its action. I tried
[toolbarItem setTarget:[ExternalObject class]];
[toolbarItem setAction:@selector(methodToRun)];

(which I assume means toolbarItem's action is [externalObject methodToRun])

No, it means "send methods to the class object of the ExternalObject class". This would be fine if "methodToRun" was a class method (see the Objective C PDF that were installed with your devtools for the difference between class and instance methods.

but the toolbar item remains greyed out (disabled) in my toolbar.

Probably because the ExternalObject class doesn't have such a class method.

My current workaround is to create an outlet in IB from mainWindow that connects to externalObject, but I think that it's a waste of resources because only this particular toolbar item out of all of mainWindow's outlets requires externalObject. For the same reason (waste of resources), I didn't initialize externalObject in mainWindow. Is there a better workaround?

You need to think of how the objects relate in your application. Who owns who, and who knows about who. How does the toolbar delegate know about instances of the ExternalObject class? Are they instance variables to the tb delegate? Are they singleton objects? You need to answer these questions before you attempt to connect actions to these objects. I think you need to run through a few more tutorials to get the feeling for how this is working.

j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Toolbar problems (From: Yuhui <email@hidden>)

  • Prev by Date: Quartz Extreme or OpenGL?
  • Next by Date: Re: Quartz Extreme or OpenGL?
  • Previous by thread: Toolbar problems
  • Next by thread: NSTextField
  • Index(es):
    • Date
    • Thread