Selecting Tab View Items in applescriptobjc

Hi All.

Getting on quite well with applescriptobjc thanks to Shane Stanley’s book. However, I’ve suddenly come up against a problem I can’t quite solve regarding selecting tab view items.

In the past using ASS I used to use something like the following to select a tab view item:

set tab view item “Info_Tab” of tab view “Main_Tab” to do xyz.

I can’t seem to do this now using applescriptobjc. Everything is connected correctly in xCode and Interface Builder but it won’t seem to select any tab view items using the following method:

script Tab_TestAppDelegate
property parent : class “NSObject”
property myWindow : missing value
property myTabView : missing value
property tabViewItem1 : missing value
property tabViewItem2 : missing value
property tabViewItem3 : missing value

on myButton_(sender)
	myTabView's selectTabViewItem_(tabViewItem2)
end myButton_

on applicationWillFinishLaunching_(aNotification)
	-- Insert code here to initialize your application before any files are opened 
end applicationWillFinishLaunching_

on applicationShouldTerminate_(sender)
	-- Insert code here to do any housekeeping before your application quits 
	return current application's NSTerminateNow
end applicationShouldTerminate_

end script

Other methods seem to work such as the selectLastTabViewItem etc but not by the specific tab view item.

Any help would be greatly appreciated!

Matt

Hi,

your code should work.
If a button is connected to the on myButton() handler, the next tabview item will be selected
until the last tabview item is reached.

The parameter in the selectNextTabViewItem_() doesn’t matter in this case.
You could pass the button reference (sender) or (me) for the script object.

If you want to select a specific tabview item, use the selectTabViewItem_() method

myTabView's selectTabViewItem_(tabViewItem3)

Note, that connecting the tab view items in Interface Builder is a bit tricky,
because unlike ObjC where Interface Builder knows the class of the UI elements,
ctrl-dragging from the delegate object catches always the top level object (the tab view itself).
In the MainMenu.xib window choose list or column view and connect the UI elements there.

Edit: You edited your post :wink:

Thank you so much!

Setting it to list view worked a treat!

Much Appreciated!

Matt