Forums > MaxMSP

Controlling sliders

March 22, 2008 | 4:15 am

I have a slider with a minimum value of zero, and a maximum value of 2.

I want to control the slider with the E and D key. I am aware of the key object and how to obtain values from the pressing of keys, but how do I use these keys to say add 0.1 to the slider when I push E, and subtract 0.1 from the slider when I push D?



MIB
March 22, 2008 | 4:23 am

One way of doing it… I used E and D in the example as you suggested…
Hope this helps.
Cheers

#P window setfont "Sans Serif" 9.;
#P flonum 222 264 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 254 209 23 196617 0.1;
#P newex 254 231 36 196617 !- 0.1;
#P message 196 211 23 196617 0.1;
#P newex 196 231 34 196617 + 0.1;
#P newex 196 180 65 196617 sel 101 100;
#P newex 196 160 40 196617 key;
#P fasten 6 0 2 1 231 283 184 283 184 227 225 227;
#P fasten 6 0 4 1 227 284 293 284 293 229 285 229;
#P fasten 4 0 6 0 259 261 227 261;
#P fasten 2 0 6 0 201 257 227 257;
#P connect 5 0 4 0;
#P connect 3 0 2 0;
#P connect 0 0 1 0;
#P fasten 1 1 5 0 228 203 259 203;
#P connect 1 0 3 0;
#P window clipboard copycount 7;


March 22, 2008 | 4:52 am

On Mar 21, 2008, at 9:15 PM, johnsoncraigsbc wrote:

> I want to control the slider with the E and D key. I am aware of the
> key object and how to obtain values from the pressing of keys, but
> how do I use these keys to say add 0.1 to the slider when I push E,
> and subtract 0.1 from the slider when I push D?

This doesn’t clip at zero and two, but you get the idea.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 297 284 29 196617 t b f;
#P newex 282 63 62 196617 prepend set;
#P message 333 255 30 196617 -0.1;
#P newex 282 308 50 196617 accum 0.;
#P flonum 282 329 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 333 234 74 196617 sel 100 101;
#P message 365 255 31 196617 0.1;
#P newex 333 213 40 196617 key;
#P user multiSlider 282 84 34 191 0. 2. 1 2681 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P connect 8 0 5 0;
#P connect 8 1 5 1;
#P connect 6 0 8 0;
#P connect 2 0 8 0;
#P connect 7 0 0 0;
#P fasten 4 0 7 0 287 352 421 352 421 57 287 57;
#P connect 1 0 3 0;
#P connect 3 1 2 0;
#P connect 3 0 6 0;
#P connect 0 0 5 0;
#P connect 5 0 4 0;
#P window clipboard copycount 9;

Chris Muir
cbm@well.com

http://www.xfade.com


March 23, 2008 | 11:51 pm

Thanks guys. The first example looks like it would work best, but how would you hook that up to control a slider?

The second example here didn’t seem to move the slider up and down at all?


March 24, 2008 | 12:18 am

On Mar 23, 2008, at 4:51 PM, johnsoncraigsbc wrote:
> The second example here didn’t seem to move the slider up and down
> at all?

What? You actually want me to test these things I post? :-)

Try this:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 297 284 29 196617 t b f;
#P newex 282 89 71 196617 prepend set 1;
#P message 333 255 30 196617 -0.1;
#P newex 282 308 50 196617 accum 0.;
#P flonum 282 329 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 333 234 74 196617 sel 100 101;
#P message 365 255 31 196617 0.1;
#P newex 333 213 40 196617 key;
#P user multiSlider 282 111 27 166 0. 2. 1 2681 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P connect 7 0 0 0;
#P fasten 4 0 7 0 287 352 421 352 421 81 287 81;
#P connect 5 0 4 0;
#P connect 0 0 5 0;
#P connect 3 0 6 0;
#P connect 3 1 2 0;
#P connect 1 0 3 0;
#P connect 2 0 8 0;
#P connect 6 0 8 0;
#P connect 8 1 5 1;
#P connect 8 0 5 0;
#P window clipboard copycount 9;

Chris Muir
cbm@well.com

http://www.xfade.com


March 24, 2008 | 1:33 am

Haha awesome, that works perfectly, cheers!


March 24, 2008 | 2:29 am

compact version:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 551 265 27 196617 + 0.;
#P flonum 551 284 36 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N coll ;
#T flags 1 0;
#T 101 0.1;
#T 100 -0.1;
#P newobj 551 244 53 196617 coll;
#P newex 551 225 40 196617 key;
#P connect 0 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P fasten 2 0 3 1 556 301 588 301 588 263 573 263;
#P window clipboard copycount 4;

best,

John


March 24, 2008 | 3:10 am

awesome, any ideas of how to stop it from going past the minimum and maximum points in the float number box?


March 24, 2008 | 3:27 am

"clip 0. 2." before the number box will do it.

J.


Viewing 9 posts - 1 through 9 (of 9 total)