Page 1 of 1

advanced skinning

Posted: Thu Sep 08, 2011 1:49 am
by kcwvc52
is there anyway to have a true custom shaped button. every time i skin a button it seems to keep the rectangle or square form (the invisible area still able to be clicked)? i want the button to be the shape of my object. if i can't do this with a button is there any other objects that can have true custom shapes from an image?

Re: advanced skinning

Posted: Thu Sep 08, 2011 7:45 am
by bn
Hi kcwvc52,

you could create a graphic with the freehand tool, freehand polygon tool or any other graphic and set its opaquen to true. turn border on or off. Then

Code: Select all

 set the backgroundpattern of grc 1 to  the id of image 1
the code for the "button" goes into the script of the graphic.

Is this the kind of effect you are looking for? Or else please explain object it is you want to turn into a button.

Kind regards

Bernd

Re: advanced skinning

Posted: Thu Sep 08, 2011 5:23 pm
by jmburnod
Hi kcwvc52, Salut Bernd

I've made a little stack with what Bernd has explaned

I try have the same behavior of the btn (set the hilite to false when the mouseloc is not within the grc)
but the mouseup don't work well. Sometimes it work sometimes not (conflict with my mousedown script?)

BUT i'm sur Bernd have a solution 8)

Best regards

Jean-Marc

Re: advanced skinning

Posted: Thu Sep 08, 2011 11:33 pm
by bn
Salut Jean-Marc,

nice stack.

To mimick the behaviour of a 'true' button I had to use a mouseMove handler and test for within. Found out that there is a difference between:

Code: Select all

point is within rect of me 
and

Code: Select all

within(me, point)
only the second one works for a non-rectangular clicking area, like in the irregularly shaped graphic you used.

And I did "close" the points of the graphic by putting the first line of the points behind the list of points. Otherwise the trigger area is not exactly within the shape of the graphic.

I attach a modified version of your stack, I think it does behave more like a regular button now: if the mouse is down and one moves the mouse outside of the trigger area the backgroundpattern changes to normal and back to clicked state if the mouse moves back into the trigger area.

Kind regards

Bernd
skinbtn2.livecode.zip
(6.12 KiB) Downloaded 447 times

Re: advanced skinning

Posted: Fri Sep 09, 2011 8:40 am
by jmburnod
Guten Morgen Bernd,

Thanks again
It work well

Kind regards

Jean-Marc