Disable a tab view/set of tabs

Hi,

Would anyone happen to know how to disable a tab view? I am using

set enabled of tab view "reboot" of tab view item "welcome" of tab view "maintabs" of window "main" to 0

That doesn’t work though. If I change “enabled” to “visible” it will hide the tab view, but I need to to be disabled, not hidden.

Can anyone help please?

Thanks! :slight_smile:

Can anyone help…?

Please…?

A tab view inherits it’s properties from the view class, not the control class, which is why it cannot handle the ‘enabled’ property. There is no ‘direct’ way of making a tab view “dead” to activity. You can however add some code which will make it hard to do anything with it or it’s embedded objects. It would help if you give some idea of what you want to achieve by disabling the tab view. I assume that you either have tabs you want to hide under certain circumstances, or that you have controls (like buttons) that you don’t want to respond to clicks or key equiv’s.

If you’re just trying to disable buttons or other objects which respond to user action, then you’ll have to manually disable/enable them. I usually set up a subroutine which handles mass toggling for certain configurations that I want to control from many methods. This way I don’t have to write it all out every time I toggle. Just pass it a boolean (true/false) parameter and it will toggle every object for you…


toggleButtons(true) --> Example subroutine call

on toggleButtons(theState)
	tell window "window"
		set enabled of button "button1" to theState
		set enabled of button "button2" to not theState <-- "not" toggles the opposite of 'theState'
		set enabled of text field "textField1" to theState
	end tell
end toggleButtons

Another method, is to limit the user to a certain tab…which will effectively disable any controls in inactive tabs, and/ or the users ability to change to another tab item. The following example uses a property to guage whether a tab view should change to another tab. If “canChangeTabs” is true, it will allow the user to go to any tab. Otherwise, the user is stuck on the current tab, and all other tabs are disabled and cannot be accessed. You can set the current tab view item to a ‘safe’ one (if necessary), and then disable the ability to change to other items to effectively ‘lock down’ the tab view. Setting the value of ‘canChangeTabs’ will enable/disable the tab view at any time.

property canChangeTabs : true --> Property which determines hether the tab view item can change

(* Attach this to your tab view's handler in IB *)
on should select tab view item theObject tab view item tabViewItem
	if canChangeTabs then
		return true
	else
		return false
	end if
end should select tab view item

(* A test button to toggle wthether the tab view item can change *)
on clicked theObject
	if name of theObject is "tabsSelectable" then
		if state of theObject is 0 then
			set canChangeTabs to false
		else
			set canChangeTabs to true
		end if
		
	end if
end clicked

Sorry you had to wait sooo long… :?
j

That worked perfectly! Thanks very much! :smiley: