Re: [Swingosc-devel] patch for EZ behaviour
Brought to you by:
sciss
From: Sciss <co...@sc...> - 2009-04-15 09:56:55
|
hi marije, thanks, it looks good. BUT: i think you are wrong with the new defaultKeyDownAction of JSCNumberField. you know that JSCTextField and JSCNumberBox are behaving a lot different than cocoa SCTextFieldOld and SCNumberBox, in that the key handling is 99% done on the server side. so SClang should _not_ - change the text colour - add characters to its string representation (this is done by the DocumentListener already; you would mess it up when duplicating this activity) - react to return and delete keys (this is done on the server) - react to cursor left and right (as we have a proper cursor/caret in the gadget unlike old-style SCNumberBox; think of the difference between SCTextFieldOld and SCTextField!) - so as far as i see, it boils down instead to: defaultKeyDownAction { arg char, modifiers, unicode; - if( unicode == 0xF700, { this.increment; ^this }); - if( unicode == 0xF703, { ^this }); - if( unicode == 0xF701, { this.decrement; ^this }); - if( unicode == 0xF702, { ^this }); - if( (char == $\r) || (char == $\n), { ^this }); // enter key - if( char.isDecDigit or: { "+-.eE".includes( char )}, { ^this }); - ^nil; // bubble if it's an invalid key So changing the text colour is IMO a bad idea, and also unnecessary as you have a proper cursor and the look-and-feel takes care of how the stuff looks, including text colours etc. secondly, i think you might create a race condition here, as you check for the return key. note that there are two event handlers registerd: a KeyListener and a NumberListener. the NumberListener gets notified about editing commits such as hitting return, and the corresponding OSC responder on the SClang side will take care of calling valueAction. At the same time KeyListener receives notification from the return hit, and eventually your new code in defaultKeyDownAction will be called. I guess the result is that valueAction is called twice. i don't have time in this moment to verify this observation, but i ask you to make sure there is no conflict with the new defaultKeyDownAction. also the checking against digits worries me. i am 99% sure this code is all wrong and needs to be removed: defaultKeyDownAction { arg char, modifiers, unicode; + var zoom = this.getScale(modifiers); - if( unicode == 0xF700, { this.increment; ^this }); + if (unicode == 0xF700, { this.increment(zoom); ^this }); - if( unicode == 0xF701, { this.decrement; ^this }); + if (unicode == 0xF701, { this.decrement(zoom); ^this }); please try this version (i don't have time in this moment to apply + check the diff). you need to be very carefully with copy+pasting code from the cocoa widgets, the internals are often not the same! thanks anyway + go ahead with the commits after checking the JSCNumberBox issue. ciao, -sciss- Am 15.04.2009 um 03:22 schrieb nescivi: > Hiho, > > how about this diff? > > sincerely, > Marije<ezdiff.diff>--------------------------------------------------- > --------------------------- > This SF.net email is sponsored by: > High Quality Requirements in a Collaborative Environment. > Download a free trial of Rational Requirements Composer Now! > http://p.sf.net/sfu/www-ibm- > com_______________________________________________ > Swingosc-devel mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swingosc-devel |