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

[sc-dev] [sc-users] Sc3 keydown functions proposal

this is more of an sc-dev issue, so i redirect it.

btw. the focus primitive is great !  good work.  that one did bug me.
i'm still trying to get a supercollider.sourceforge.net cvs faq done.
i'll try tomorrow.

re: the consuming thing.
i guess it was Java's old system that i had read about years ago.
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
		^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);
		if (key == $[, {
			this.value = this.value - (1/this.bounds.width);
} // 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:

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

sc-users mailing list