“addShortcut” does not work properly within folders, they are placed wrong, always at Y-position 0.

“addShortcut” does not work properly within folders, they are placed wrong, always at Y-position 0.

I have a folder, grid 8×12. Placed 2 shortcuts in row 1 and column 1 so the folder has a size of 8×5 when opened. Area 1/1 to 7/4 (0-based positions) is reserved for the area I want to add shortcuts dynamically.

addShortcut(“Label”, new Intent(), x*colW, y*RowH) places the shortcut at x*colW/0 (colW and rowH are calculated from container size and grid, those values are okay).

Tried dettaching and moving after adding, still the same. “Dettach by default”  makes it worse, shortcut’s size is smaller than grid cell size.

It works when folder is in Edit-mode (full screen 8×12 grid shown), but not when folder is in Normal-mode.

Is this a bug, or am I just doing it wrong? Then what is the correct way?

]]>
(Next Post) »

9 Commentsto “addShortcut” does not work properly within folders, they are placed wrong, always at Y-position 0.

  1. Anonymous says:

    < ![CDATA[

    Pierre Hébert Lukas Morawietz Any ideas?

    ]]>

  2. Anonymous says:

    < ![CDATA[

    I always create my shortcuts on 0,0 and then move them. I have no idea why you get a problem in folders.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Lukas Morawietz Damn, you’re right! I made a stupid error: in my case the folder when in normal view has a height of 8×5 (only 5 of 12 rows filled vertically with spacers). I divided the size returned by getHeight() by the total number of grid rows… so calculated row height is only 5/12 of what I expected. 😩

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Is there any easy way to better do a correct calculation?

    ]]>

  5. Anonymous says:

    < ![CDATA[

    I don’t understand what you want to compute.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Lukas Morawietz I have reserved an area in the folder for shortcuts that are added by script in a grid layout. To do so, I need to calculate the locations to place the shortcuts at. Would be great if one could specifiy the target as grid cell (i.e. row 2, column 3) instead of X/Y-coordinates.

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Oops, there is a method: setCell (left, top, right, bottom). Why didn’t I find this earlier? Would’ve made many things easier. Strange syntax however, left/right top/bottom instead of left/width top/height.

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Oh, that’s why I didn’t understand what you wanted to do 😁

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Unfortunately I cannot change this API (well, in fact I could, but that would be “annoying” due to the way it has been implemented). The same code is used to convert a “touch” position in an item position regardless of its grid attachement, and I don’t wish to duplicate the code. The setCell method is indeed a fair enough alternative. The left/top/right/bottom is the usual way to express rect coordinates in drawing toolkits, and in Skia in particular (the one of Android, and Chrome). On the software side it generally makes things a bit easier, although the difference is small.

    ]]>

Leave a Reply

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