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

Re: [sc-dev] Sc3 keydown functions proposal

thanks heiko !  i was just going to ask where you were with this since
i'm looking even in sc2 for this kind of cascading.

On Monday, July 29, 2002, at 03:12 PM, heiko goelzer wrote:

Thanks for your ideas cris and jan. I included some of them in this version. It seems like a good idea to have control over everything keydown related in
the keyDownFunction variable, e.g. no extra consum flag...

Now you go:
yourView.keyDownAction_({arg view, key, modifier; yourJob ;true});
to have yourJob being done and the keydown passed on to the parent view.

but i just realized that it is smarter to return nil if you want it to bubble up.

then if there isn't a keyDownAction for a view,


it returns nil

keyDown { arg key,modifiers;

handleKeyDownBubbling { arg view, key,modifiers;


this should be faster.

if(pass && this.isKindOf(SCTopView).not, {
			// call local keydown action of parent view
			this.parent.handleKeyDownBubbling(view, key, modifiers);

you should just override handleKeyDownBubbling in SCTopView to pass it
then to the globalKeyDown action.

key up !  i haven't had a chance to compile this in and play with it yet,
but i will.

i guess these keyboards can detect up to 4 keys at once. did you find anything
about that ?

i'm using my sc2 keyboard a lot, covered with controls. i've just been finishing a real time sequencing system that records messages to objects. they are all triggered
from keyboard right now, so its of interest to me.

To call the defaultKeyDownAction befor yourJob without passing on:
yourView.keyDownAction_({arg view, key, mod;
view.defaultKeyDownAction(key,mod); yourJob ; false});

I decided to pass as first argument, the view that first receives the
keydown. It migth be an option to pass the whole tree of passed Views
instead? I don't know.

you would rarely need that, and when you did you can simply follow the parent
chain up from the view.

The keyUp is handed over the exact same way. There is a difference though:
keyUp sets the variable keyTyped to the released key.
And as keyDowns keep repeating with the key repeat rate you set in global os
preferences (you can even turn repetition off if you want) keyUp appears
only once.
hmm. so you would have in your keydown action something that waits for the keyUp
to appear ?

Next I will include keyEvents into it, I promise.

how about handlers that can be used in place of the functions ?
when they are valued, they can handle different actions (like sending notifications
to things that were listening for a specific keyEvent).

so you can write a separate class and just use them to stick into keydown actions.

my KeyDown uses a dictionary so it doesn't have to ask a lot of if statements. you could do the same thing, but it wouldn't be a global responder. you would stick them in the actions of eg. a composite view. they would have various functions registered
for specific keys/modifiers and can fire off when one matches.
you could also stick one in the global action of course.

i have to post the newest version soon because i caught a bug. the modifier matching is quite useful i think, and the code was a little bit of a head scratcher. if you are going to write handlers, then take a look at this KeyDown code and steal.