Archive for October, 2009

Jedit javascript macro filename problem

Monday, October 19th, 2009

I still have it, but now I really think I nailed it here. Originally reported here and I just freaking can’t believe that the one who closed this bug could not reproduce it.

EDIT: Thanks, Steve Gough – then it wasn’t my imagination :) Now we can expect much better javascript macros with Jedit.

Cancel KeyboardEvent.KEY_DOWN in as3 TextField

Friday, October 9th, 2009

For flash people this is probably easy, but it gave me a slight headache: I want to catch a couple of keys in a TextField and do things; but since the key has also been catched by the control, a black square appears (in my case) which I’d rather not have. Since the KEY_DOWN event is not cancellable and I couldn’t find a solution with the propagation phase / priority, I did end up cancelling TEXT_INPUT itself:

addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
addEventListener(TextEvent.TEXT_INPUT, cancelKey);

//...

private function onKeyDown(event:KeyboardEvent):void
{
cancelChar = false;
if ((event.ctrlKey) && (event.charCode == "b".charCodeAt(0))) {
cancelChar = true;
//do something with ctrl+b here
}
}

private function cancelKey(event:TextEvent):void
{
if (cancelChar) {
event.preventDefault();
cancelChar = false;
}
}