Telling a checkbox inside a tab viw, inside another tab view

Hi,
I am trying to set a check box that is inside a tab view, that is inside another tab view to turn on (become checked).

I am using this code:

set state of button "macid" of tab view item "symbian" of tab view "tabs" of tab view item "alertbutton" of tab view "preftabs" to 1

I keep getting the NSReceiverEvaluationScriptError: 4 (1) error. I think that means the object doesn’t exist. Can anyone tell me what I am doing wrong?

Thanks!!

Well, I don’t know about the tecnical bit in this, but nested tab views !?! :shock: I’d recommend either making larger windows with more controls, extra windows for related options, or just plain old rethinking of the design. Back to the larger window things, if you need to group the controls, labeled boxes are available. Another option is menus.

That aside, check that your names in the script and IB are exactly the same, it’s a problem I often have (“doh! that’s souRce not souce!” hours later)

Also, it might help to make the code clearer to use the constant “on state” as the value you’re setting to.

One final thing… the top level of your references is not the window… should it be? -->button “x” of … of main window

You are right about the referencing being wrong… try putting the window at the top, and checking your spelling… for simple testing do something like this;


log main window
log main window's tab view "prefTabs"
log main window's tab view "prefTabs"'s tab view item "alertButton"
--… 

From what I can tell, there is a bug in apple’s support for nested tab views. As mooresan said, perhaps this is a good thing. :? Actually, I CAN imaging scenarios where a nested tab view might be useful, so I’ll not bash it but offer a solution.

A common workaround for object ID problems is to identify them programmatically in their awake from nib handler, assign them to a variable, and then address them by their variable in any future references. I attached the ‘macid’ button’s awake from nib handler to the the code below, which saves a reference to it as the property variable ‘theCheckbox’. Then just use that when you need to reference the checkbox, rather than the long path to it. in this example, a separate button will toggle the checkbox on/off when pressed.

NOTE: this will not work unless the button is visible. You can’t manipulate the button’s properties if it’s tab view item and the parent tab view item’s aren’t the currently active ones. If you’ve got tabs other than the ones containing the button active, you’ll continue to throw an error.

property theCheckbox : missing value

on clicked theObject
	if name of theObject is "toggleCheckbox" then
		tell theCheckbox
			set myState to (state as boolean)
			set state to not myState
		end tell
	end if
end clicked

on awake from nib theObject
	if name of theObject is "macid" then
		set theCheckbox to theObject
	end if
end awake from nib

Seems like nested tab support is an oversight on apple’s part?!

Adios,
j

This feels more like design than oversight… tabs were not meant to be nested… http://digilander.libero.it/chiediloapippo/Engineering/iarchitect/tabs.htm

if your main tab view’s tab items are that complex maybe think about something like what you see at: http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGLayout/chapter_11_section_5.html

You could indent menu items to show grouping… to create this effect, create a tab view in IB, set up all the sub views how you want, then in the tab views attributes pane, set it to “tabless” then drag and drop a popup button to somewhere outside the box (just to be sure it doesn’t end up inside…) then reposition it as shown in the HIG link above… Set up the menu items using indentation to indicate nesting and then control drag from the popup button (not the menu or it’s items) to the tabview… connect it to takeSelectedTabViewItemFromSender:

Note that the tab view items must be in the same order as the menu items.

Thanks for the help everyone, I have changed the design not to include nested tab views :slight_smile: It works better, and looks better too. :smiley: