Help with toolbar

So I had a working toolbar for my app, that simply switched the currently selected tab of a tabview. But then I wanted to add another button, that is named “Clean”. When I added it, the toolbar still worked, but the Clean button did not appear. Here is the script:

global currentView, panelViews

on awake from nib theObject
	set documentToolbar to make new toolbar at end with properties {name:"document toolbar", identifier:"document toolbar identifier", allows customization:true, auto sizes cells:true, display mode:default display mode, size mode:default size mode}
	
	set allowed identifiers of documentToolbar to {"finder item identifier", "dock item identifier", "dashboard item identifier", "safari item identifier", "menu bar item identifier", "misc item identifier", "clean item identifier", "print item identifier", "customize toolbar item identifer", "flexible space item identifer", "space item identifier", "separator item identifier"}
	set default identifiers of documentToolbar to {"finder item identifier", "dock item identifier", "dashboard item identifier", "safari item identifier", "menu bar item identifier", "misc item identifier", "clean item identifier"}
	set selectable identifiers of documentToolbar to {"finder item identifier", "dock item identifier", "dashboard item identifier", "safari item identifier", "menu bar item identifier", "misc item identifier", "clean item identifier"}
	
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"finder item identifier", name:"finder item", label:(get localized string "Finder" from table "Toolbar"), palette label:(get localized string "Finder" from table "Toolbar"), tool tip:(get localized string "Finder options." from table "Toolbar"), image name:"Finder.icns"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"dock item identifier", name:"dock item", label:(get localized string "Dock" from table "Toolbar"), palette label:(get localized string "Dock" from table "Toolbar"), tool tip:(get localized string "Dock options." from table "Toolbar"), image name:"Dock.icns"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"dashboard item identifier", name:"dashboard item", label:(get localized string "Dashboard" from table "Toolbar"), palette label:(get localized string "Dashboard" from table "Toolbar"), tool tip:(get localized string "Dashboard options." from table "Toolbar"), image name:"dashboard.png"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"safari item identifier", name:"safari item", label:(get localized string "Safari" from table "Toolbar"), palette label:(get localized string "Safari" from table "Toolbar"), tool tip:(get localized string "Safari options." from table "Toolbar"), image name:"Safari.icns"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"menu bar item identifier", name:"menu bar item", label:(get localized string "Menu Bar" from table "Toolbar"), palette label:(get localized string "Menu Bar" from table "Toolbar"), tool tip:(get localized string "Menu Bar options." from table "Toolbar"), image name:"DesktopScreenEffectsPref.icns"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"misc item identifier", name:"misc item", label:(get localized string "Misc." from table "Toolbar"), palette label:(get localized string "Misc." from table "Toolbar"), tool tip:(get localized string "Misc. options." from table "Toolbar"), image name:"notfound.png"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"clean item identifier", name:"clean item", label:(get localized string "Clean" from table "Toolbar"), palette label:(get localized string "Clean" from table "Toolbar"), tool tip:(get localized string "Clean." from table "Toolbar"), image name:""}
	
	set toolbar of theObject to documentToolbar
	
	set selected item identifier of documentToolbar to "finder item identifier"
	show window "main"
end awake from nib

on clicked toolbar item theObject
	if identifier of theObject is "finder item identifier" then
		tell tab view "tabview" of window "main"
			set the current tab view item to tab view item "Finder"
		end tell
		tell window "main"
			set title to "Finder"
		end tell
	else if identifier of theObject is "dock item identifier" then
		tell tab view "tabview" of window "main"
			set the current tab view item to tab view item "Dock"
		end tell
		tell window "main"
			set title to "Dock"
		end tell
	else if identifier of theObject is "dashboard item identifier" then
		tell tab view "tabview" of window "main"
			set the current tab view item to tab view item "Dashboard"
		end tell
		tell window "main"
			set title to "Dashboard"
		end tell
	else if identifier of theObject is "safari item identifier" then
		tell tab view "tabview" of window "main"
			set the current tab view item to tab view item "Safari"
		end tell
		tell window "main"
			set title to "Safari"
		end tell
	else if identifier of theObject is "menu bar item identifier" then
		tell tab view "tabview" of window "main"
			set the current tab view item to tab view item "Menu Bar"
		end tell
		tell window "main"
			set title to "Menu Bar"
		end tell
	else if identifier of theObject is "misc item identifier" then
		tell tab view "tabview" of window "main"
			set the current tab view item to tab view item "Misc."
		end tell
		tell window "main"
			set title to "Misc."
		end tell
	else if identifier of theObject is "clean item identifier" then
		tell tab view "tabview" of window "main"
			set the current tab view item to tab view item "Clean"
		end tell
		tell window "main"
			set title to "Clean"
		end tell
	end if
end clicked toolbar item

on launched theObject
	--call method "setTitle:" of window "main" with parameter "tartampion"
	--call method "NSUnifiedTitleAndToolbarWindowMask:" of window "main" with parameter 0
end launched

Any help you could give me? Did I make a mistake?

And then on a sidenote, is there any chance someone could explain to me how to make the whole app into separate views, which slide up and down to reveal different panels (like in the popular application OnyX). If you want to see what I already have going, my application is LeopardMOD.

Help please! =D

Hello,

make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"clean item identifier", name:"clean item", label:(get localized string "Clean" from table "Toolbar"), palette label:(get localized string "Clean" from table "Toolbar"), tool tip:(get localized string "Clean." from table "Toolbar"), image name:""}

From what I can see, you haven’t specified an image for your “Clean” toolbar item. You’ve currently got it set to “”, so since the application can’t find the image, it doesn’t display an icon.

Quill

Have you considered making the toolbar in Interface Builder?

According to what I have read, IB doesn’t make toolbars…

Is that bad information? By the way, I fixed it, but I would still like to know how to convert it into separate windows (or views, as I think they are). I dunno why it worked, but when I set Customization to False, then it worked. :confused:

Edit: Your right, you CAN make them in IB…when did that happen? My question about views still stands.

Interface Builder 3.0

Edit: Also, if your toolbar items and tab view items are appropriately named, then you could try something like this:

on clicked toolbar item theObject
	tell tab view "tabview" of window "main"
		set current tab view item to to tab view item (name of theObject)
	end tell
	tell window "main" to set title to (label of theObject)
end clicked toolbar item

The only trouble with creating toolbars in Interface Builder 3 is that your application will only work on Mac OS X 10.5 Leopard. I eventually decided to code toolbars the old way because I wanted my applications to also run on 10.4 Tiger…

Quill

Well then again I ask, ow would I make them totally separate windows? In an example someone sent me, that used views/windows, they had this in their script as well:

set panelViews to {}
	set end of panelViews to call method "contentView" of (window "appearance")
	set end of panelViews to call method "contentView" of (window "maintain")
	set end of panelViews to call method "contentView" of (window "clean")
	set end of panelViews to call method "contentView" of (window "automate")
	set end of panelViews to call method "contentView" of (window "logs")
	set end of panelViews to call method "contentView" of (window "utils")
	set end of panelViews to call method "contentView" of (window "infos")
	set end of panelViews to call method "contentView" of (window "prefs")
	
	call method "retain" of (item 1 of panelViews)
	call method "retain" of (item 2 of panelViews)
	call method "retain" of (item 3 of panelViews)
	call method "retain" of (item 4 of panelViews)
	call method "retain" of (item 5 of panelViews)
	call method "retain" of (item 6 of panelViews)
	call method "retain" of (item 7 of panelViews)
	call method "retain" of (item 8 of panelViews)

What does all this mean, and how would I have to set it up in order to get it to work?

Do you mean that you want to have the same interface (i.e. a main window with a toolbar that displays different content in that window depending on which toolbar item is selected), but instead of having all the content in a tab view, you want to have the content of each tab view item in its own window (which isn’t ever shown to the user) in Interface Builder (and then when the application runs, the content gets moved out of that window into your main window when its toolbar item is selected)?

As for the script, I’m not sure what the call method “retain” does, but in the first section you’re placing the contents of various windows into a list. However, you don’t need to call an Objective-C method; you can set the content view of a window using just Applescript Studio. For example, instead of:

set end of panelViews to call method "contentView" of (window "appearance")

…you can write:

set end of panelViews to content view of window "appearance"

Quill