I have several tabs and after the user clicks a button in one tab to set off a calculation (on a tab called Convert) I’d like the display to change to another tab (Viewer).
In ASS I used
set the current tab view item to tab view item “Viewer” -
If you have 2 tabs, Convert and Viewer (in that order) any of the 3 methods below will work if you put them into the handler that’s connected to your calculation button
script TabsAppDelegate
property parent : class "NSObject"
property myTabs : missing value --Connected to the TabView in IB
on buttonPush_(sender)
--Do the calculations here
--myTabs's selectTabViewItemAtIndex_(1)
--myTabs's selectNextTabViewItem_(sender)
myTabs's selectLastTabViewItem_(sender)
end buttonPush_
end script
These methods can all be found in the NSTabView Class Reference in the documents
Initializing the first tab on launching the program dont works. I’ve set my first tab inside the attributes inspector as the “Initial Tab” - no success. Also tried this code:
script TabsAppDelegate
property parent : class "NSObject"
property myTabs : missing value --Connected to the TabView in IB
on applicationWillFinishLaunching_(aNotification)
myTabs's selectTabViewItemAtIndex_(0)
end applicationWillFinishLaunching_
end script
Also without success but also no errors in the debug output. I’ve 3 tabs, from index 0 …2.
Any help is appreciated.
Rebewslin
Model: MacBook 2.1 3/500
AppleScript: XCode 4.2.1
Browser: Safari 534.51.22
Operating System: Mac OS X (10.7)
Not in my project
I’ve deleted all bindings from the NSTabView. “Initial Tab” shows the name of my first tab. But, if the program is started it uses the last setted tab before restart.
Nevertheless, thank you!
Rebewslin
Model: MacBook 2.1 3/500
AppleScript: XCode 4.2.1
Browser: Safari 534.51.22
Operating System: Mac OS X (10.7)
I’ve run into this behavior with restorable windows also. There are two ways around it. You can uncheck the Restorable check box in the window’s identity inspector, but, of course, you will lose the behaviors for the window as well as your tabs (like its size and position when the app was last closed). The other way, which only affects what you want, is to put the “myTabs’s selectTabViewItemAtIndex_(0)” line in the applicationDidFinishLaunching method instead of the applicationWillFinishLaunching method.