Marty's slider

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
conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Marty's slider

Post by conde » Tue Jan 17, 2012 7:20 pm

Hi,
I'm using Marty's horizontal slider in 2 cards. After moving the slider knob "k" from 100 to i.e. 40 and going to card 2 the value is 40 but the knob is on position 100. What can I do to move the knob on card 2 to the pos of 40?

Thanks for helping.

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

Re: Marty's slider

Post by Klaus » Tue Jan 17, 2012 8:46 pm

Hi conde,

what is "Marty's slider"?


Best

Klaus

EDIT:
Ah, found it, will take a look...

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

Re: Marty's slider

Post by dunbarx » Tue Jan 17, 2012 11:42 pm

Whatever Marty's slider is, can you store the thumbPosition (or whatever so corresponds) in a custom property and reset it on opencard?

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

Re: Marty's slider

Post by jmburnod » Wed Jan 18, 2012 12:17 am

Hi,

It is possible using group to do that ( tested with Marty Slider)

1. Set the sharedText of fld "theValue_h" to true
2. Select btn "k", img "Hsliderbar", fld "theValue_h of the horizontal Slider
3. Clic at "Group" on the toolbar
4. Set the name of the group to "myScrollbar"
5. Set the behaviorBackground of group "myScrollbar" to true
6. Type "new cd" in the messagesBox, the new cd have the group "myScrollbar"
and it keep the value and position of the slider

Best regards

Jean-Marc
https://alternatic.ch

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Marty's slider

Post by conde » Wed Jan 18, 2012 12:55 pm

Many, many thanks to Jean-Marc. As a newbie I would never have thought with the behaviorBackground.
Today my trial period is over and I'm going now to order Livecode. Then I will try Jean-Marc's suggestion.

This forum here is a nice comuntity with many helpful people. I hope that someday I can help others.

Kind regards,
Guera

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Marty's slider

Post by conde » Mon Jan 23, 2012 11:22 am

Sorry - I'm too stupid for math.
The script of Marty’s horizontal slider:

Code: Select all

on mouseDown
  # INSERT YOUR MINIMUM (LEFT) VALUE
  put 2000 into minValue --in my case = wait 2000 milliseconds (30 BPM)
  # INSERT YOUR MAXIMUM (RIGHT) VALUE
  put 200 into maxValue --in my case = wait 200 milliseconds (300 BPM)
  
  # GET THE OFFSET OF THE CLICK SPOT AND CENTER OF THE BTN
  # THIS WILL PREVENT THE BTN FROM JUMPING WHEN YOU START TO DRAG
  put (the mouseH - item 1 of the loc of me) into cX
  
  # the number you see added or subtracted at the end of the next 3 lines
  # is to tweak the position of the slider button so it stops where you want
  # THIS IS IN ADDITION TO ADDING THE VALUE OF cX
  put (the left of image "BGSliderRate")+(the width of me/2)+cX -12 into Lstop
  put (the right of image "BGSliderRate")-(the width of me/2)+cX +12 into Rstop
  put item 2 of the loc of image "BGSliderRate" into yLoc
   put (maxValue-minValue)/(Rstop-Lstop) into scaleFactor
  put true into canMove
end mouseDown

on mouseMove x,y
  if not canMove then exit mouseMove
  put min(Rstop,max(Lstop,x)) into xLoc
  set loc of me to xLoc-cX,yLoc
  # you may need to add values to following: xLoc and yLoc
  # to position the value fld where you want
  set loc of fld "theValue_h" to xLoc-cX,yLoc+20
  # The following line calculates the value which you would want to
  # also put into use for the actual functioning of the slider
  put round((xLoc-Lstop)*scaleFactor)+minValue into fld "theValue_h"
  put round((xLoc-Lstop)*scaleFactor)+minValue into pBPM
end mouseMove
Now I would like to see the BPMs in the fld "theValue_h" ???

Thanks for helping.

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Marty's slider

Post by conde » Tue Jan 24, 2012 9:56 pm

It's a pity. No response? :cry: Or is this posting in the wrong category?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Marty's slider

Post by bn » Tue Jan 24, 2012 11:37 pm

Hi Conde,

I don't really understand what you want. Your script should work in the context of Marty's Slider.

Here is a version of the horizontal slider with min 200 and max 2000 that displays the value below the slider in field "theValue_h"

martysBPM.livecode.zip
(3.88 KiB) Downloaded 215 times
KInd regards

Bernd

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Marty's slider

Post by conde » Wed Jan 25, 2012 1:57 am

Bernd - danke for your answer and stack.
My problem is: in the script I've modified (code see above) the minValue = 2000 and maxValue = 200. The variable pBPM goes to a wait command. Wait 2000 milliseconds (30 BeatsPerMinute - slider knob left = slow) and wait 200 milliseconds (300 bpm - slider knob on the right = fast). The slider works fine in the wait command. What I mean is that I can see in “the_Value_h“ the real beats per minute.

Danke für Deine Mühe.

Guera

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Marty's slider

Post by bn » Wed Jan 25, 2012 9:27 am

Hi Guera,

I did not get that you wanted the "real" beats to show up in the field.

try to replace the last lines of the mouseMove handler with this:

Code: Select all

     put round((xLoc-Lstop)*scaleFactor)+minValue into tRawValue
     put round(60000/tRawValue) into fld "theValue_h"
     put round((xLoc-Lstop)*scaleFactor)+minValue into pBPM
end mouseMove
The beats should be in field "theValue_h"

Kind regards and greetings to Stuttgart

Bernd

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Marty's slider

Post by conde » Wed Jan 25, 2012 12:02 pm

Hi Bernd - YOU made my day! Thank you sooooo much.

Greetings to Bochum.

Guera

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”