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

Re: [Sc-devel] [bug] SCTextView.keyUpAction




Hi Scott

It's not only keyUpAction that ill-behaves. keyDownAction triggers an action 
when merely asking for focusing on a button:

Example:

(
var win, butt;

win = SCWindow("test", Rect(100, 100, 320, 343)).front;

// ------------------- this group shows wrong functionality
SCTextView(win, Rect(40, 40, 51, 12))
.font_(Font("Helvetica", 9))
.string_("440")
.keyDownAction_({arg view, key, mod, unicode; 
if(unicode == 13, {
butt.focus(true);
});
});

butt = SCButton(win, Rect(120, 50, 174, 80))
.font_(Font("Helvetica", 9))
.states_([["button", Color.black, Color.clear]])
.action_({ |bt|
"BUTTON ACTION".postln; //should not be triggered from butt1.focus(true)
});

// ---------------------------------- we can compare with this
SCButton(win, Rect(40, 80, 50, 16))
.font_(Font("Helvetica", 9))
.states_([["button", Color.black, Color.clear]])
.action_({ |bt|
butt.focus(true);
});



//---------------------------------- my solution is to use keyUpAction


SCTextView(win, Rect(40, 120, 51, 12))
.font_(Font("Helvetica", 9))
.string_("440")
.keyUpAction_({arg view, key, mod, unicode; 
if(unicode == 13, {
butt.focus(true);
});
});
)




SCTextView.keyUpAction seems to fire twice - I never noticed this before:

(
var win, txt;

win = SCWindow.new.front;
txt = SCTextView(win,win.bounds.moveTo(0,0))
.keyDownAction_({ "down".postln })
.keyUpAction_({ "up".postln })
.focus(true);
)

- Scott
_______________________________________________
Sc-devel mailing list