Tab View encapsulated elements not responding, despite "awake from nib

Correction: it turns out the code below does work - my error was elsewhere in my code. Thanks for the help Woodenbrain!

I’ve been having a problem that’s been reported on these boards several times, and I have tried the suggested solutions.

I have a drop-down list on each of two tabs. I would like to disable the list programmatically.

I have tried the two solutions below. The first just tries to reset the list by referencing it directly, the second tries to reset the list through reference objects created during awake from nib. Both set the current tab before trying to manipulate the list, but neither actually disables the list.

referencing directly:


on resetInterface()
	tell tab view "MyTabView" of window "main"
		set the current tab view item of tab view¬
		 "MyTabView" of window "main" to tab view item¬
		 "tab2"
		delete every menu item of menu of popup button¬
		 "itemList" of view of tab view item "tab2" of¬
		  tab view "MyTabView" of window "main"
		make new menu item at the end of menu items of¬
		 menu of popup button "itemList" of view of tab¬
		 view item "tab2" of tab view "MyTabView" of¬
		 window "main" with properties {tag:0,¬
		 title:"Select an item", enabled:true}
		tell popup button "itemList" of tab view item¬
		 "tab2" of tab view "MyTabView" of window¬
		 "main" to set visible to false
	end tell
end resetInterface

awake from nib reference:


on awake from nib theObject
	if the name of theObject is "itemList" then
		set itemList to theObject
	end if
end awake from nib

on resetInterface()
	tell tab view "MyTabView" of window "main"
		set the current tab view item of tab view¬
		 "MyTabView" of window "main" to tab view item¬
		 "tab2"
		delete every menu item of menu of itemList		
		make new menu item at the end of menu items of¬
		 menu of itemList with properties {tag:0,¬
		 title:"Select an item", enabled:true}
		tell itemList to set visible to false
	end tell
end resetInterface

did you try just:

set visible of popup button “itemList” of tab view item¬
“tab2” of tab view “MyTabView” of window¬
“main” to false

Thanks Woodenbrain,

That didn’t work I’m afraid. The problem seems to be that the contents of the tab are not hearing the applescript events. Solutions on the board point to making sure that the tab is set as the current tab before manipulating elements, and making references to the objects in their on awake from nib events. However, these solutions don’t seem to work for me.

I realize that I forgot to mention that while I’m manipulating the tab contents I have a panel open over the window (to show a progress bar). I don’t know if the panel being open is interferring with the events being passed.

Conrad

I’ve found my mistake. It wasn’t in this code after all. Typical oversight. I’m sorry. The above are still good references for accessing elements in a tab, so I hope it wasn’t be a big waste of everyone’s time.