Using Little Arrows

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Using Little Arrows

Post by Ultravibe » Sun Mar 08, 2015 7:44 pm

Hi there!
I want to use Little arrows to adjust timer parameters (minutes,seconds)
which handlers is tell me about: "up" arrow is pressed, "down" arrow is pressed
i mean how it is spelling: "on UpArrow" or smthg like that...
i need to use it in Little arrows script

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Using Little Arrows

Post by sefrojones » Sun Mar 08, 2015 7:56 pm

Do you mean the arrow keys? If so, check out the "arrowkey" message in the dictionary.

Code: Select all

on arrowkey pKey
   switch pKey
      case "up"
         --do up stuff
         
         break
      case "down"
         --do down stuff
           
         break
      case "left"
         --do left stuff
          
         break
      case "right"
         --do right stuff
            
         break
   end switch
end arrowkey
--Sefro

Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Re: Using Little Arrows

Post by Ultravibe » Sun Mar 08, 2015 8:12 pm

Sefro, no!
I use element like on photo.
Which messages is sent to element when arrow "Up" or "Down" is pressed? I mean arrows of control element
Attachments
little_arrows.jpg
little_arrows.jpg (14.51 KiB) Viewed 8536 times

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Using Little Arrows

Post by SparkOut » Sun Mar 08, 2015 8:44 pm

Aha, this is actually a scrollbar, with the type set to littlearrows. So you can use the scrollbarDrag message:

Code: Select all

on scrollbarDrag tThumbPos
   put tThumbPos into field 1
end scrollbarDrag
You can set the startValue and endValue to restrict the range, and the lineInc to choose by how much the value will change on each press of the little arrow.
Note that you can't set a negative value for startValue or endValue in the property inspector, but you can by script.

Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Re: Using Little Arrows

Post by Ultravibe » Sun Mar 08, 2015 9:01 pm

And what if i just need to know which little arrow is pressed? (Without adding or subtracting thumbPos and using it!)
Just detect which arrow...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Using Little Arrows

Post by dunbarx » Sun Mar 08, 2015 9:16 pm

Hi.

I do not think that there is a native way to determine which of the "little arrows" is pressed. (I did not know, like Sparkout, what this actually was, until I allowed the cursor to hover over the scrollbar icon in the toolbar).

Anyway, I would set a custom property of the scrollbar with the scrollBarDrag message, and test to see if the new thumbPos is above or below that value. I think you already had this concept in mind.

Craig Newman

Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Re: Using Little Arrows

Post by Ultravibe » Sun Mar 08, 2015 10:23 pm

Yes,Craig, thank you!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Using Little Arrows

Post by Simon » Sun Mar 08, 2015 10:32 pm

How about this;

Code: Select all

on mouseUp
   if the thumbPosition of me > 500 then
      put "up"
   else
      put "down"
   end if
   set the thumbPosition of me to 500
end mouseUp

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Using Little Arrows

Post by jmburnod » Sun Mar 08, 2015 10:44 pm

This should work:

Code: Select all

on scrollbarDrag tThumbPos
   if tThumbPos > fld 1 then
      put "up"
   else
      put "down"
   end if
   put tThumbPos into field 1
end scrollbarDrag
Best regards
Jean-Marc
https://alternatic.ch

Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Re: Using Little Arrows

Post by Ultravibe » Mon Mar 09, 2015 12:10 am

Jean-Marc, thank you!
I do the same algorhythm and it works!
But it's much better the way that Simon advised)))))

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Using Little Arrows

Post by Klaus » Mon Mar 09, 2015 12:24 am

Hi guys,

use "on scrollbarLineDec" and "on scrollbarLineInc" together with an appropiate value
for "lineInc" in the inspector for the "little arrows" :D


Best

Klaus

Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Re: Using Little Arrows

Post by Ultravibe » Mon Mar 09, 2015 7:04 am

Thank you, Klaus!
This way is much comfortable! Don't need to evaluate where the value of scrollbar "goes": up or down ))))
Just two messages Increase and Decrease ))))
It's exactly what i'm lookin for!

Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Re: Using Little Arrows

Post by Ultravibe » Mon Mar 09, 2015 9:43 am

Klaus! By the way, is there a property of Scrollbar to ignore countinous mouse pushing?
I mean "one press = one action", and it wouldn't repeat to increase (or decrease) the value even if i hold mouse button and don't release it

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Using Little Arrows

Post by Klaus » Mon Mar 09, 2015 1:01 pm

Ultravibe wrote:Klaus! By the way, is there a property of Scrollbar to ignore countinous mouse pushing?
I mean "one press = one action", and it wouldn't repeat to increase (or decrease) the value even if i hold mouse button and don't release it
Not sure I understand, but I don't think there is a property for this.
Maybe you can "fake" it by simply scripting "mouseup" instead of any scrollbar message.

Ultravibe
Posts: 62
Joined: Sat Jan 17, 2015 12:06 pm

Re: Using Little Arrows

Post by Ultravibe » Mon Mar 09, 2015 3:03 pm

Klaus wrote:
Ultravibe wrote:Klaus! By the way, is there a property of Scrollbar to ignore countinous mouse pushing?
I mean "one press = one action", and it wouldn't repeat to increase (or decrease) the value even if i hold mouse button and don't release it
Not sure I understand, but I don't think there is a property for this.
Maybe you can "fake" it by simply scripting "mouseup" instead of any scrollbar message.
Actually, i've been searching the messages like "scrollbarInc" and "scrollbarDec" to simplify the scripts))))

Post Reply

Return to “Talking LiveCode”