How to set editable of table column containing checkboxes

I have a table with 2 columns. The first column contains check boxes. I have discovered that setting the editable attribute of that column to false does not prevent the check boxes from being checked/unchecked by the user. How do I set the editable attribute of the check boxes of that column to be editable or not?

Example of non-working code:

set editable of table column "column1" of table view "theTable" of scroll view "theTable" of window "main" to false

Thanks in advance,
Brad Bumgarner, CTA

If you want the buttons to be disabled (and grayed out) all of the time, then you can do something like this in the awake from nib handler of the table view…

on awake from nib theObject
	set enabled of data cell of table column "Column" of theObject to false
	tell theObject to update
end awake from nib

If you want to be able to toggle the ‘enabled-ness’ of the buttons, then you could do something on the “on clicked” handler, like this…

on clicked theObject
	if name of theObject is "EnableButtons" then
		tell table view "Table" of scroll view "Scroll" of window "Window"
			set enabled of data cell of table column "Column" to (state of theObject)
			update
		end tell
	end if
end clicked

Note that both of the above methods completely gray out the buttons. Because buttons (and button cells) don’t support an “editable” property… only text-bearing objects respond to editable… you can really only use the “enabled” property. If you want the buttons to look normal, but not be able to be changed, you could use the “change cell value” handler of the table view. This ONLY works when you’re constructing the table data without using a data source (with ‘number of rows’ and ‘cell value’ and a source list)…

set OKToChangeButtons to true
on change cell value theObject row theRow table column tableColumn value theValue
	if (OKToChangeButtons) then
		set item theRow of sourceList to theValue
	end if
end change cell value

Use the handler to capture the value that the button has changed to, then change the corresponding list item to reflect that value. The handler automatically tells the cell to re-draw, and when it does it grabs the value from the list again and the new value is shown. The effectiveness of this method is greatly dependent on whether your setup is compatible with manipulating your data this way.

j

Damn! I was close! :lol:

Thanks for the input as always.

Brad Bumgarner, CTA

Thanks Jobu !:wink: