How to get an imagewell button to show CICN?

Here's where to discuss using Stéphane Leys' very well done alternative runtime editor. If you're a control freak at runtime you have to check this out!

How to get an imagewell button to show CICN?

Postby drpitcairn » Wed Jun 03, 2009 9:34 pm

I have been reading the User Manual and LG trying to understand how an imagewell button can show icons and CICN contentType. So far, no luck. I was able to move the CICN datafork over to my project but the LG does not tell me how to set up the script for it to show in the button. Can someone show me a sample script?

Thanks,
Richard
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: How to get an imagewell button to show CICN?

Postby S. Leys » Thu Jun 04, 2009 5:58 am

rpitcairn wrote:I have been reading the User Manual and LG trying to understand how an imagewell button can show icons and CICN contentType. So far, no luck. I was able to move the CICN datafork over to my project but the LG does not tell me how to set up the script for it to show in the button. Can someone show me a sample script?

Well, I've been working on this soooooooooo long ago, the only thing I can remember is that it was a nightmare. Some button styles may accept some types of resource from the data or the resource fork. I once made a little table of which buttons may have which icons but I couldn't find it.
You can use the IP (icon Picker, with a button selected, select "icon" in the "edit" button of the PI), it will do its best to show you the icons which may be used with the currently selected button (if a button is disabled in the IP, it means that this option isn't available). You may have to click the "rebuild" button to actually see in the selector the icons of the source selected in the popup buttons. I tested it this morning and could set the icon of an imagewell to a typeCICN from the sharedfile. But it seems that it has changed, the roundrect buttons don't show the icon any more (if they ever did) OTOH, bevel buttons do.
imagewell buttons may also have a typePICT but those must be in the resource fork and you'll find this kind of resource only in old OS9 files. I could import a typePICT from an old version of AppleWorks.

Since I never use icons myself (I assume that people who will use my interfaces can read ;-)) I'm not very inclined to revisit this stuff, it would be the assurance of wasting a lot of time on something I'll never use.

However, I made a few tests.
In the Resource module, I opened the current project in the left field and the sharedfile in the right field, I D&D the cicn "alarm clock" icon (ID 202) from the sharedfile to my project, then in an imagewell button :
Code: Select all
on mouseup
    set contenttype of me to typeCICN
    set icon of me to 202
end mouseup

Result :
card button ID 334.jpeg
card button ID 334.jpeg (1.92 KiB) Viewed 3016 times


With the PI, you'll need to click the "rebuild" button to see this :
Image 2.png
Image 2.png (37.86 KiB) Viewed 3016 times


Or with the sharedfile selected as source file :
Image 1.png
Image 1.png (58.6 KiB) Viewed 3017 times


But all these little icons are a bit obsolete in OS X.

I an imagewell button, I could also do :
set picturedata of me to picturedata of cd grc "obs"
Which will probably be more handy than typePICT resources in OS X.
I've included the possibility of setting the picturedata of imagewell buttons in the PI.

You probably already know that, when clicking with the browse tool a grc whose picturedata and allowdrag are true (see the misc tab in the preferences), MPI will pick this object, allowing to drop it (you must hold down the mouse until the cursor becomes an arrow). SC handles this drop automatically for graphics or fields whose allowdrop is true (and allowobjects for fields). Since SC doesn't do it for imagewell buttons, I've added a script for doing it and while I was at it, I also did it for text graphics. But I had to define the favoriteflavors of these objects and set their allodrop to true. This applies to objects dropped from the tools h module, these properties are not set automatically if you draw the object with the tool but may be set via the PI and the uprops module. And I also had to set the allowfavorites to true by default.

These new features will be available in the next release of MPI with many others.

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am

Re: How to get an imagewell button to show CICN?

Postby drpitcairn » Thu Jun 04, 2009 6:21 am

Stephane,
Whew! I had no idea it was so complicated. I was thinking of using a fancier looking button than just a rectangle with a name. What do you do now to make a custom button? Make a graphic in some other program and somehow import it?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: How to get an imagewell button to show CICN?

Postby S. Leys » Thu Jun 04, 2009 6:33 am

rpitcairn wrote:Whew! I had no idea it was so complicated. I was thinking of using a fancier looking button than just a rectangle with a name. What do you do now to make a custom button? Make a graphic in some other program and somehow import it?

You can do this since a graphic may have picturedata and will receive mouse messages, so you can have a grc acting like a button.
But why just don't you try to set the icon of a button with the IP as I explained ?
As you can see in a script in the previous mail, you must not only set the contenttype of the button, you also need to set its icon (of a type matching the contenttype, of course).
This icon stuff is not under SC control, the buttons and the icons they may have or not is controlled by the system. Again, SC can do only what the OS allows and MPI can do only what SC allows. And what the OS allows is not always straightforward (for using a euphemism).
So, you will have to experiment a bit and see what works or not.

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am

Re: How to get an imagewell button to show CICN?

Postby S. Leys » Thu Jun 04, 2009 6:37 am

rpitcairn wrote:I had no idea it was so complicated.

PS : With the IP though, having an imagewell showing a cicn is quite easy (just remember to click the "rebuild" button if the picker doesn't show the cicns).
Or use the recipe I posted.

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am

Re: How to get an imagewell button to show CICN?

Postby drpitcairn » Thu Jun 04, 2009 9:53 am

Stephane,
I was able to do it using your script:
Code: Select all
    on mouseup
        set contenttype of me to typeCICN
        set icon of me to 202
    end mouseup

I put in the ID number for one the one I wanted to use and went fine. You won't believe how many permutations I tried last night trying to get it to work, like:
Code: Select all
set contentType of cd btn 6 to ID202

and many other attempts. Wonder why the LG doesn't show how to do this? All it says for typeCICN is this:
Code: Select all
Set [the] contentType of buttonDescriptor to typeCICN
Set the contentType of cd btn "Export" to typeCICN

What I needed was the second line
Code: Select all
set icon of me to 202.

Would have helped to have that in the Guide. I realize the LG has nothing to do with you, but you can see how I get stuck.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona


Return to Using MPI

Who is online

Users browsing this forum: No registered users and 1 guest

cron