Page 1 of 1

icon 201317 split button

Posted: Tue Apr 15, 2008 2:25 pm
by hamlynart
Hi Folks,

I'd like to use icon 201317 as a button. It shows an up and a down arrow so the button needs to have a script to run depending on which part is clicked. I'd also like it to increment more if the mouse is held down. Would anyone know how this could be done or where I could find an example?

Many thanks in advance.

Jim H

Posted: Tue Apr 15, 2008 3:28 pm
by BvG
I just tried it out:

Code: Select all

on mouseDown
 doCalc
end mouseDown

on mouseStilldown
  doCalc
end mouseStilldown

on mouseUp
  set the icon of me to 1005
end mouseUp

on mouseRelease
  set the icon of me to 1005
end mouseRelease

on doCalc
  if the mouseV- the top of me >= the height of me div 2 then
    set the icon of me to 1008
    subtract one from field "showvalue"
  else
    set the icon of me to 1009
    add one to field "showvalue"
  end if
end doCalc
You need:
  • a field called "showvalue"
  • a button with the style set to transparent, showname false, autohilite false, script as above
  • the three images 201317, 201318, 201319 placed onto the stack
Note that the id's of the images are set automatically, and that you need to adjust those for the script to work.

There also seems to be a problem with doubleclick-hold (click, then quickly hold the mouse down), due to the way Rev handles doubleclicks, but I didn't find a workaround to that, and it's not a common action.

have fun
Björnke

PS: this was nice to try out, and work's surprisingly well, you can even "scrub" while mousestilldown (it'll always count up or down depending on the mouse position)

icon 201317 split button

Posted: Tue Apr 15, 2008 4:03 pm
by hamlynart
That's brilliant!

And if I repeat the doCalc on mouseStilldown it increments faster - great.

Thanks a million.

Jim H

Re: icon 201317 split button

Posted: Tue Apr 15, 2008 7:47 pm
by BvG
hamlynart wrote:And if I repeat the doCalc on mouseStilldown it increments faster - great.
I suggest to, whenever possible, use a build in way for doing things. So to vary the speed of a moustStillDown it's best to use the idleRate property.

You did read all the documentation entries for terms you don't know yet and just heard about on the forum, right :wink: