[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] Sc3 keydown functions proposal




hi,

one of the features of java is that you have keyPressed, keyReleased and keyTyped,
would be nice to have that in sc as well.

if the keyDown would call an action like SCSlider:
something like:
(class)
...
keyDown{var key, modifiers;
	setKeyEvent(key, modifiers);
	action.value
	}
defaultAction = { gui...default action}
action = {defaultAction.value}
...

then you can override the action in your object and include the defaultAction or not.


re: the consuming thing.
i guess it was Java's old system that i had read about years ago.
its also in the new one ...
the difference to sc is only that it works the other way around:
in java you implement a KeyListener interface in your class, in sc you add a action to your listener. which ends up to be the same ...
its done in a different way than what you laid out.
in the action function itself you consume or not the event.

usually rather than get
keyDown { arg  key, modifiers;

you get
keyDown { arg keyDownEvent;

which would be a simple object

KeyDownEvent {
	var key,modifiers;
	
}

(but you could easily add cool modifier matching methods to it to match
CAPS etc.   btw. if you want to mess with this, i just today FIXED some
major bugs with my modifiers matching in KeyDown sc2)

you the user would :

wobblyGui.keyDown = { arg keyDownEvent;
if(keyDownEvent.key.asChar = $q and: { keyDownEvent.modifier & 4 }, { // or whatever
		wobbly.goApeShit;
		^false; // i handled it here
	},{
		^true; // i don't care about this event go up the chain
	})
};

i would say make the keyDown function default to:

{
		if (key == $r, { this.value = 1.0.rand; ^this });
		if (key == $n, { this.value = 0.0; ^this });
		if (key == $x, { this.value = 1.0; ^this });
		if (key == $c, { this.value = 0.5; ^this });
		if (key == $], {
			this.value = this.value + (1/this.bounds.width);
			^this
		});
		if (key == $[, {
			this.value = this.value - (1/this.bounds.width);
			^this
		});
} // example from SCSlider

so if you set your own key down handler (or set it to nil), it overrides it.



also read this a bit, it criticizes this bubbling method and explains java event listeners:
http://216.239.39.100/search?q=cache:UzFwIsW9CCkC:www.lv2.clara.co.uk/ch3.
pdf+keydown+event+consume+bubble&hl=en&ie=UTF-8

but seriously, you should study how cocoa does it. its probably better :)




On Thursday, July 18, 2002, at 07:26 PM, heiko goelzer wrote:

no better examples yet, but I pulled out the standard keydowns and made
consuming possible as proposed by crucial.

    Heiko

I will come up with a new version soon, integrating consumers...

Heiko


_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users


____________________
http://crucial-systems.com

_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev