custom buttons

Wilhelm Sanke sanke at hrz.uni-kassel.de
Thu Feb 26 14:32:36 EST 2004


On Feb 25, 2004 Thomas McGrath III wrote:


>My Bad,,,,,,
>
>I didn't include the images in that file.
>
>this one has it I swear....
>
>go URL "http://users.adelphia.net/~3mcgrath/Buttons.rev"
>
>
>Tom


Hi Tom,

Here is still another solution - somewhat different from yours in "Buttons.rev" - based on the recommendations of the stack "grafikbuttons" we put on our ftp-server for our students.

Put the "Bdown" image *on top* of the "BUp" image. Hide the "BDown" image.
Put the script to toggle between up and down into the "BUp" image, i.e. show and hide the "BDown" image from there, in this way there is no problem with receiving the "mousedown" and "Mouseup" messages.
As your "BDown" and "BUp" images are of different size you have to adjust - make smaller - the rect of the underlying "BUp" image when you show the "BDown" image on top of it.

Sample script for the "BUp" image (I had renamed the images to "top.png" and "base.png"):

Local OldRect, NewRect
on mousedown
  put the rect of me into OldRect
  put OldRect into NewRect
  add 4 to item 1 of NewRect
  add 4 to item 2 of NewRect
  set the rect of me to NewRect
  show image "base.png"
end mousedown
on mouseUp
  set the rect of me to OldRect
  hide image "base.png"
end mouseUp

There remains your "airplane.gif". Put a button with the airplane as the icon on top of the two images. Uncheck all checkboxes of tab "Behavior" and "Appearance".

Put the following script into this button:

on mousedown
  move me relative 2,2
  send mousedown to image "top.png"
end mousedown
on mouseUp
  move me relative -2,-2
  send "Mouseup" to image "top.png"
end mouseUp

Group the three controls.

The movement of this group is much smoother than of the groups in your stack "buttons.rev".--

Thanks to Chipp Walters, there is his "ButtonGadget" that addresses related, but different issues. I use his tool relatively often and additionally design my own png-images with the very affordable tool "RealDrawPro" (www.mediachance.com).

For some of my applications I would appreciate a new feature that makes it possible to place button names/labels directly *on* an icon, not just right, left, or below. Thus it would be possible to use custom buttons whose labels could be changed during runtime (this is of course not possible with the ButtonGadget stack); e.g. language learning exercises where the labels of the custom buttons change with each new problem could benefit from such a feature.

Of course you could also set the backpatterns of buttons to the custom images and then have the labels directly on top. But this solution is viable only in case of rectangular images, as with non-rectangular images the transparent parts of the PNGs appear as black.

Regards,

Wilhelm Sanke




More information about the use-livecode mailing list