Hello, I’m not good in scripting but i try and learn every day.
(sorry for my english, hope you will understand :-))
Also a big Thanks to the community.
Now here is a script. Maybe someone find it useful.
I have one desktop with an analog clock widget. I use WallpaperChanger and if i change the background the kontrast of th clock widget is low. I want to move the widget to another position by “longtap” the desktop.
The touch position will be calculated by the script and send to the “setPosition” of the object. The half of the objects hight and width must substracted to get the object center. In my case i add this manually because i don’t know ho to do this in a script.
After longtap on the desktop the clock moves to the tap position.
I know i could open the edit mode and move the widget, but for me is this script an more elegant solution.
Here is the script
(tipps for optimization are welcome)
var e = LL.getEvent();
var ey = e.getTouchY();
var ex = e.getTouchX();
LL.getCurrentDesktop().
getItemByName(‘clock’).
setPosition(ex -116, ey -108);
LL.getCurrentDesktop().
getItemByName(‘clock’).
setVisibility(true);
]]>
< ![CDATA[
This should work (although not tested)
Why were you setting it’s visibility each time? (Only asking)
var e = LL.getEvent();
var ey = e.getTouchY();
var ex = e.getTouchX();
var item=LL.getCurrentDesktop().
getItemByName(‘clock’);
item.setPosition(ex -item.getWidth()*item.getScaleX()/2, ey -item.getHeight()*item.getScaleY()/2);
]]>
< ![CDATA[
Thanks! The visibility is set, because another script hides all (just two) desktop elements.
]]>