icon 201317 split button

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

icon 201317 split button

Post by hamlynart » Tue Apr 15, 2008 2:25 pm

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Tue Apr 15, 2008 3:28 pm

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)
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

icon 201317 split button

Post by hamlynart » Tue Apr 15, 2008 4:03 pm

That's brilliant!

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

Thanks a million.

Jim H

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: icon 201317 split button

Post by BvG » Tue Apr 15, 2008 7:47 pm

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:
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply