Dear Script-magicians

Dear Script-magicians,

This javascript thing is driving me nuts. I’m trying to do something very simple, just for fun… I created a small (1×2) panel and called that “mini”. It’s detached from the grid and not pinned. I’m just trying to move the damned thing using a script that runs when the panel is touched. Only thing that happens is an error message:

at line 8: ReferenceError: Cannot call method “setposition” of null

That should mean the getitem method returned null.What am I doing wrong? Here’s the code:

var cont=LL.getEvent().getContainer();

var bar=cont.getItemByLabel(“mini”);

rc=bar.setPosition(1,1);

]]>

3 Commentsto Dear Script-magicians

  1. Anonymous says:

    < ![CDATA[

    I guess you are running the script from the click background event of the panel


    What event.getItem return is the panel as container, not the desktop containing the panel


    You can just use


    var bar=LL.getEvent().getContainer().getOpener()

    ]]>

  2. Anonymous says:

    < ![CDATA[

     TrianguloY you’re right. It worked that way. I guess my error was more a javascript error than not using the LL object right. Trying to learn this because 1: I would like to do some special stuff in LLX, and 2: I’ll have to adapt a lot of existing javascript (and write some new) at work soon. Do you have some advice where to start? I already looked at some of the examples in the wiki, but haven’t the slightest clue what they’re doing

    ]]>

  3. Anonymous says:

    < ![CDATA[

    It wasn’t a JavaScript error, you were using it incorrectly. When you did getItemByLabel, the launcher couldn’t find any item labeled ‘mini’ (wait a moment…you should have used getItemByName). So it returned null, and you can’t set the position of null 😉


    Don’t worry, it’s a tricky error (I mean, not a basic one)



    If you know JavaScript as a language (and I guess you do) you are fine. If looking at examples didn’t help you, read the scripting api page, do some tests, and ask here any question as you did. I don’t have any advice, and I’m not good at giving them 😛 sorry.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *