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