Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » A Notched Scroll Selector
- ge-b
- Scratcher
100+ posts
A Notched Scroll Selector
How would you make a custom scroll bar like a slider variable with only a few numbers so it ‘slides’ in segments?
Edit: Unresolved!
What I want:
https://scratch.mit.edu/projects/239550127/ is my attempt, but the mouse rounding just isn't right. It gets more obvious the less notches you put.
Edit: Unresolved!
What I want:
define Segment Scroll from (x left) to (x right) with (no. notches) notches
https://scratch.mit.edu/projects/239550127/ is my attempt, but the mouse rounding just isn't right. It gets more obvious the less notches you put.
Last edited by ge-b (Aug. 20, 2018 10:31:50)
I am a competent human [citation needed]
- gor-dee
- Scratcher
1000+ posts
A Notched Scroll Selector
forever
go to x: ((round ((mouse x) / (50))) * (50)) y: (0)
end
- DD-8861
- Scratcher
100+ posts
A Notched Scroll Selector
If you want the variable slider to only have a few numbers, you can right click it in the stage and select ‘set variable min and max’.
Then you can set it to only slide between 1-4 or whatever numbers you want.
Then you can set it to only slide between 1-4 or whatever numbers you want.
- ge-b
- Scratcher
100+ posts
A Notched Scroll Selector
Not my question. A ‘custom’ slider. If you want the variable slider to only have a few numbers, you can right click it in the stage and select ‘set variable min and max’.
Then you can set it to only slide between 1-4 or whatever numbers you want.
bump.
Last edited by ge-b (Aug. 20, 2018 10:38:49)
I am a competent human [citation needed]
- burger-pro
- Scratcher
65 posts
A Notched Scroll Selector
I would like to find a music for my intro can you help me ?
- gor-dee
- Scratcher
1000+ posts
A Notched Scroll Selector
expanding on what I first said…
when green flag clicked
go to x: (0) y: (0)
forever
if <<(distance to [mouse-pointer v]) < [50]> and <mouse down?>> then
go to x: ((round ((mouse x) / (20))) * (20)) y: (0)
if <(x position) < [-100]> then
set x to (-100)
end
if <(x position) > [100]> then
set x to (100)
end
end
end
- deck26
- Scratcher
1000+ posts
A Notched Scroll Selector
Please post in a more appropriate forum and create your own topic there - eg Requests. I would like to find a music for my intro can you help me ?
- ge-b
- Scratcher
100+ posts
A Notched Scroll Selector
A bit messy for numbers that don't divide into each other. Any better options? expanding on what I first said…when green flag clicked
go to x: (0) y: (0)
forever
if <<(distance to [mouse-pointer v]) < [50]> and <mouse down?>> then
go to x: ((round ((mouse x) / (20))) * (20)) y: (0)
if <(x position) < [-100]> then
set x to (-100)
end
if <(x position) > [100]> then
set x to (100)
end
end
end
I am a competent human [citation needed]
- gor-dee
- Scratcher
1000+ posts
A Notched Scroll Selector
I looked at your code, does this work…
define segment scroll (notch) (left) (right)Output is
set [notch dist v] to (((right) - (left)) / (notch))
go to x: ((round ((mouse x) / (notch dist))) * (notch dist)) y: (0)
if <(x position) < (left)> then
set x to (left)
end
if <(x position) > (right)> then
set x to (right)
end
(x position)
Last edited by gor-dee (Aug. 20, 2018 16:07:20)
- ge-b
- Scratcher
100+ posts
A Notched Scroll Selector
I looked at your code, does this work…define segment scroll (notch) (left) (right)Output is
set [notch dist v] to (((right) - (left)) / (notch))
go to x: ((round ((mouse x) / (notch dist))) * (notch dist)) y: (0)
if <(x position) < (left)> then
set x to (left)
end
if <(x position) > (right)> then
set x to (right)
end(x position)
Gives one more notch than the input. Tried replacing the part with a
((notch)-(1))but has the same messiness problem, which is caused by the method of simply setting the x position to the min or the max whenever it's outside the range.
I give up. Gonna ram it out of myself.
Last edited by ge-b (Aug. 20, 2018 17:07:43)
I am a competent human [citation needed]
- BereketY
- Scratcher
500+ posts
A Notched Scroll Selector
I remember seeing this in a project. I don't remember the project, but I saw it in use from littlebuny's 3d engine.
when [up ] key pressed
if <not <key [up ] pressed?>> then
broadcast [do what you want if you scroll up ]
end
when [down ] key pressedBasically, the mouse wheel is detected instead of the arrow key.
if <not <key [down ] pressed?>> then
broadcast [do what you want if you scroll down ]
end
Last edited by BereketY (Aug. 20, 2018 23:05:38)
Arrays speak to me on a spiritual level.
- Discussion Forums
- » Help with Scripts
- » A Notched Scroll Selector