Not bad.

Not bad.

The new Touch event is…is…awesome.

(No matter where the items are)

]]>
« (Previous Post)
(Next Post) »

17 Commentsto Not bad.

  1. Anonymous says:

    < ![CDATA[

    omg, awesome! Can’t wait to have more time to code some more scripts myself…

    ]]>

  2. Anonymous says:

    < ![CDATA[

    any chance for some code? πŸ™‚

    ]]>

  3. Anonymous says:

    < ![CDATA[

    I didn’t want to post it yet because pierre said the Touch event is still under construction, and perhaps in the future it can change a lot.


    (And also because when I made the video the code was a complete mess)



    However I can post it for testing purpose…just let me modify a little thing

    ]]>

  4. Anonymous says:

    < ![CDATA[

    aha… ok …


    I know what code can look like when you just doing it for yourself for testing… πŸ˜‰


    (spaghetti code)Β 


    Thanx for posting…

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Well, not spaghetti, just very bad implemented (when I have an idea I just code it, then is when I use more functions instead of copy/paste, indent it to make clear, some comments…)



    Ok, here you have. Just set it in the Touch event of a folder.


    Touch to open it, keep and swipe to select an item, release the finger to launch.


    It work with rotated items, but with the out box, the one when selecting it in edit mode. (Could be done with the real one…but this is enough)



    I notice something: when you try and the folder is not loaded yet (when you open it first after a reset or so) the values are wrong, keep in mind. Otherwise it works fine.



    I hope you understand the code more or less (I recommend you to long click the Touch event to go to the help page.)



    This is all…have fun!

    ]]>

  6. Anonymous says:

    < ![CDATA[

    function isinside(it,xy){


    var tl = [it.getPositionX(),it.getPositionY()];


    var siz= [it.getWidth()*it.getScaleX(), it.getHeight()*it.getScaleY()];


    var rot=it.getRotation()*Math.PI/180;


    var sincos=[Math.abs(Math.sin(rot)),Math.abs(Math.cos(rot))];


    var br = [tl[0]+siz[1]*sincos[0]+siz[0]*sincos[1],tl[1]+siz[0]*sincos[0]+siz[1]*sincos[1]];


    return xy[0]>tl[0]&&xy[1]>tl[1]&&xy[0]

    }





    var x = event.getX();


    var y = event.getY();



    var action=event.getAction();


    if(action==MotionEvent.ACTION_DOWN){


    item.open();


    cont=item.getParent();


    fold=item.getContainer();



    helper=[(cont.translateIntoScreenCoordX(item.getPositionX())-fold.translateIntoScreenCoordX(0))/fold.getPositionScale(),(cont.translateIntoScreenCoordY(item.getPositionY())-fold.translateIntoScreenCoordY(0))/fold.getPositionScale(),fold.getPositionScale()];


    items=fold.getItems();



    fill=LL.createImage(1,1);


    fill.draw().drawARGB(255,125,125,125);


    empty=LL.createImage(1,1);


    }else{



    if(action==MotionEvent.ACTION_UP&&event.eventTime-event.downTime<250)return true;//click to open




    var point=[helper[0]+x/helper[2],helper[1]+y/helper[2]];



    for(var j=items.getLength()-1;j>=0;–j){



    var current=items.getAt(j);


    if(current.getType()!=”Shortcut”)continue;



    if(isinside(current,point)){


    if(action==MotionEvent.ACTION_MOVE) current.setBoxBackground(fill,”n”);


    else if(action==MotionEvent.ACTION_UP) current.launch();


    //break; //uncomment this to allow only one item (top-most)


    }else{


    if(action==MotionEvent.ACTION_MOVE) current.setBoxBackground(empty,”n”);


    }


    }


    if(action==MotionEvent.ACTION_UP) item.close();


    }



    return true;

    ]]>

  7. Anonymous says:

    < ![CDATA[

    thanx!

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Superb!

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Thanks πŸ˜€


    Now you know why I wanted to ‘select’ an item πŸ˜‰

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Yes. The manual way is more “safe”

    ]]>

  11. Anonymous says:

    < ![CDATA[

    I like it. But if you just tap the folder it opens but not closes again… (use a timeout?)

    ]]>

  12. Anonymous says:

    < ![CDATA[

    That feature is something I added to be able to edit the folder πŸ˜‰


    To disable it just comment the line where it says: ‘click to open’

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Yes, saw it already. I was writing before having a closer look to the script

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Btw: this is how I use it…


    Nearly the same setup as yours, but needs a shortcut to all apps in parent

    ]]>

  15. Anonymous says:

    < ![CDATA[

    var x=event.getX();


    var y=event.getY();



    var action=event.getAction();


    s:switch(action)


    {


    case MotionEvent.ACTION_DOWN:


    empty=LL.createImage(1,1);


    cont=item.getParent();


    open=true;


    setTimeout(longPress,200);


    break s;


    case MotionEvent.ACTION_MOVE:


    if(item.isOpen())


    {


    var point=[helper[0]+x/helper[2],helper[1]+y/helper[2]];


    for(j=items.getLength()-1;j>=0;–j)


    {


    var current=items.getAt(j);


    if(current.getType()!=”Shortcut”)continue;


    if(isinside(current,point))


    {


    var img=current.getBoxBackground(“s”);


    current.setBoxBackground(img,”n”);


    }


    else current.setBoxBackground(empty,”n”);


    }


    }


    break s;


    case MotionEvent.ACTION_UP:


    open=false;


    if(typeof helper===’undefined’&&item.isOpen())break s;


    if(item.isOpen())


    {



    var point=[helper[0]+x/helper[2],helper[1]+y/helper[2]];


    for(j=items.getLength()-1;j>=0;–j)


    {


    var current=items.getAt(j);


    if(current.getType()!=”Shortcut”)continue;


    if(isinside(current,point))


    {


    current.launch();


    item.close();


    break s;


    }


    }


    }


    if(event.eventTime-(typeof first===’undefined’||first==-1?event.downTime:first)<300)


    {


    if(typeof first!=’undefined’&&first!=-1)


    {


    doubleTap();


    break s;


    }


    else


    {


    first=event.downTime;


    setTimeout(singleTap,300);


    }


    }


    else item.close();


    break s;


    }


    return true;




    function longPress()


    {


    if(!open)return;


    item.open();


    fold=item.getContainer();


    items=fold.getItems();


    for(var j=items.getLength()-1;j>=0;–j)


    {


    var current=items.getAt(j);current.setBoxBackground(empty,”n”);


    }


    load();


    }



    function singleTap()


    {


    if(first==event.downTime)


    {LL.getCurrentDesktop().getItemByLabel(“All Apps”).launch();


    item.close();


    }


    first=-1;


    }



    function doubleTap()


    {


    item.open();


    first=-1;


    }



    function load()


    {


    if(fold.getWidth()==0)


    {


    setTimeout(load,50);


    return;


    }


    var pin=item.getProperties().getString(“i.pinMode”);helper=[((pin[0]==”X”?item.getPositionX():cont.translateIntoScreenCoordX(item.getPositionX()))-fold.translateIntoScreenCoordX(0))/fold.getPositionScale(),((pin.indexOf(“Y”)!=-1?item.getPositionY():cont.translateIntoScreenCoordY(item.getPositionY()))-fold.translateIntoScreenCoordY(0))/fold.getPositionScale(),fold.getPositionScale()];


    }



    function isinside(it,xy)


    {


    var tl=[it.getPositionX(),it.getPositionY()];


    var siz=[it.getWidth()*it.getScaleX(),it.getHeight()*it.getScaleY()];


    var rot=it.getRotation()*Math.PI/180;


    var sincos=[Math.abs(Math.sin(rot)),Math.abs(Math.cos(rot))];


    var br=[tl[0]+siz[1]*sincos[0]+siz[0]*sincos[1],tl[1]+siz[0]*sincos[0]+siz[1]*sincos[1]];


    return xy[0]>tl[0]&&xy[1]>tl[1]&&xy[0]

    }ο»Ώ

    ]]>

  16. Anonymous says:

    < ![CDATA[

    I really like the idea. I’m currently using the code above on my homescreen. I’ll make a video later…



    I have improved the following things of your version:


    – fix for pinned folder


    – 3 actions: single tap, double tap and the long press swipe around seen in the video


    – using the selected background instead of the rectangle (I’ve set a simple circle to it for all items) I think it looks a lot better than the rectangle

    ]]>

  17. Anonymous says:

    < ![CDATA[

    Solved the first load problem.

    ]]>

Leave a Reply

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