Changing tabs

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” -

How do I do it now?

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

Ric

Thanks

I use this too, works like a charm. One problem:

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)

Hi,

setting Initial Tab in Interface Builder must work unless you have bound the key to a AppDelegate class property or to Shared User Defaults controller

Not in my project :frowning:
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)

It seems that the reason is Lion’s new feature to restore the last session of a program

Ok, thats possible. Thanks you!

I will check my program within Snow Leopard on my working machine tomorrow. Update follows.

Rebewslin

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.

Ric

Thank you!

Yep, it is as expected: Within 10.6.8 no problem - the first tab is automatically activated. Lion restores the last opened tab - always.

The call inside the “applicationDidFinishLaunching”-Handler did the trick! It works, also within Lion.

Rebewslin