Re: Dynamically change button cell image within a table view
Re: Dynamically change button cell image within a table view
- Subject: Re: Dynamically change button cell image within a table view
- From: Philip Aker <email@hidden>
- Date: Mon, 18 Feb 2008 21:16:46 -0800
On 2008-02-18, at 16:51:32, Andrew Thomson wrote:
Thanks for all your help, but I appear to be missing something.
You have to address the button cell as the intersection of row number and column identifier in a named table -- not a data source -- and have the handler wiring hooked up in Interface Builder. That's why I specifically mentioned ' will display cell' -- which is one place to legitimately specify a different cell image [1]. In example 2 below, it looks like you're trying to set the image of a button directly. That's not the same concept as _button cells_ -- which are the sub-items of matrices, tables, or other container views. In the simple button case, the call is direct. Here, n is 'name of theObject'.
else if (n is "button") then set image of theObject to load image "img2" end if
[1]: If you have a bunch of images, it might be more cost effective to pre-load them into a script property in one of the early application handlers.
Below are two code examples but neither work. Any feedback would be greatly appreciated. Thanks. --Andrew
EXAMPLE 1: set theDataRow to make new data row at end of data rows of theDataSource set theCell to the data cell "icon" of theDataRow set img to load image "img_class" set theCell to call method "setImage:" of theCell with parameter img
EXAMPLE 2: on clicked theObject set img to load image "img_class" call method "setImage:" of theOject with parameter img end clicked
On Monday, February 18, 2008, at 04:14AM, "Philip Aker" < email@hidden> wrote: On 2008-02-17, at 20:53:47, Andrew Thomson wrote:
I would love it if you could point me to one? The ones I've found in the archive exhaustively cover image cells but next to nothing about setting the image of a button cell. The class reference for NSButtonCell mentions the setImage method but I can't find any examples specific to NSButtonCells and my implementation of the method doesn't yield any results (nor errors). Any help would be appreciated. --Andrew
I misread your post and was indeed thinking of image cells. Here's how to use setImage for a button cell in a table (for instance in 'will display cell'):
set img to load image "img2" call method "setImage:" of theCell with parameter img
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden