Re: [FreeJ] need help with java script

dyne.org open discussions
Author: MrGoil
Date:  
To: FreeJ mailinglist
Subject: Re: [FreeJ] need help with java script
Hi ppl!

ok. u already noticed it's filter, not effect.

I just noticed, selected_layer() is missing in the doc, ups!

Another thing: get the selected layer when pressing the key, if u select
an other layer, __kbd_sel is not up to date.

Use kdb.released_* in favor to pressed, because pressed has got autofire!
(lol, also missing in the doc. Sorry!)

kbd = new KeyboardController();
register_controller(kbd);

cart = new Filter("Cartoon")

kbd.released_a = function() {
    selected_layer().add_filter(cart);

}
// or more save:
kbd.released_b = function() {
    var layer = selected_layer(); // returns false if none
    if (layer) {
        layer.rem_filter(cart);
    }
}

MrGoil

transformat@??? schrieb:
> hi vincent,
> thank you for your tips and your java script example.
> yesterday,a friend who is much more experienced in programming
> than me,helped me to solve the problem...
> here is what we ve done.
>
> kbd = new KeyboardController();
> register_controller(kbd);
> __kbd_sel = selected_layer
>
> cart = new Filter("Cartoon")
>
> kbd.pressed_a = function() {__kbd_sel.add_filter(cart);}
> kbd.pressed_b = function() {__kbd_sel.rem_filter(cart);}
>
> bye