Can't get NSToolbar to work
Can't get NSToolbar to work
- Subject: Can't get NSToolbar to work
- From: Markus Hanauska <email@hidden>
- Date: Fri, 13 Jun 2003 13:23:19 +0200
I want to thank all people who helped me with my last problem (the
multi-Window app); all input from you was really helpful! Thanks a lot.
Now if someone could tell me why the code below my signature doesn't
work, you could make me very happy again :-)
window is connected, don't worry about that. Everything works fine if I
don't return a NSArray from toolbarDefaultItemIdentifiers and
toolbarAllowedItemIdentifiers, but null as result.
This is of course just a stupid test program, not code from my real
app.
The error looks like that (no error during compile time, but it fails
to run):
2003-06-13 13:11:53.252 NSToolbarTest[1338] *** -[NSToolbarItem
isEqualToString:]: selector not recognized
2003-06-13 13:11:53.265 NSToolbarTest[1338] AppKitJava: uncaught
exception NSInvalidArgumentException (*** -[NSToolbarItem
isEqualToString:]: selector not recognized)
2003-06-13 13:11:53.267 NSToolbarTest[1338] AppKitJava: exception =
NSInvalidArgumentException: *** -[NSToolbarItem isEqualToString:]:
selector not recognized
Stack Trace:
NSInvalidArgumentException: *** -[NSToolbarItem isEqualToString:]:
selector not recognized
at com.apple.cocoa.application.NSWindow.setToolbar(Native Method)
at Toolbar.awakeFromNib(Toolbar.java:28)
2003-06-13 13:11:53.332 NSToolbarTest[1338] AppKitJava: terminating.
NSToolbarTest has exited with status 1.
A C++ program, almost identical in function (just that it uses an
NSDictionary instead of a simple array to hold the items) works without
any problems. I just don't know about which selector the app is
complaining here and what isEqualToString has to do with it.
--
Best Regards,
Markus Hanauska
/* Toolbar */
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
public class Toolbar extends NSObject implements NSToolbar.Delegate {
public NSWindow window; /* IBOutlet */
private NSToolbarItem[] items;
public void awakeFromNib() {
NSToolbar bar = new NSToolbar("test");
bar.setDelegate(this);
NSSelector action =
new NSSelector("click",
new Class[] {NSToolbarItem.class});
items = new NSToolbarItem[100];
for (int i = 0; i < 100; i++) {
items[i] = new NSToolbarItem("" + i);
items[i].setLabel("Item " + i);
items[i].setTarget(this);
items[i].setAction(action);
}
window.setToolbar(bar);
}
public NSToolbarItem toolbarItemForItemIdentifier(NSToolbar bar,
String id, boolean bool) {
int i = Integer.parseInt(id);
return items[i];
}
public NSArray toolbarDefaultItemIdentifiers(NSToolbar bar) {
return new NSArray(items);
}
public NSArray toolbarAllowedItemIdentifiers(NSToolbar bar) {
return new NSArray(items);
}
public void click(NSToolbarItem i) {
System.out.println("Click on " + i.label());
}
}
_______________________________________________
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.