Hi!
Hi!
I’m a long-term user of LL and LLX and I’m experimenting with Scripts lately since we had some JavaScript at the university.
But now I’m stuck at a (at least that’s my suspicion) type cast problem.
If I run this script from the items menu I get the following error:
var desktop = LL.getCurrentDesktop();
var it=LL.getEvent().getItem();
var folder = desktop.getItemByName(“Internet”);
desktop.moveItem(it, folder);
At line 4: Can’t find method net.pierrox.lightning_launcher.script.api.Container.moveItem(net.pierrox.lightning_launcher.script.api.Shortcut,net.pierrox.lightning_launcher.script.api.Folder).
MoveItem is defined by (Item, Container) instead of (Shortcut, Folder), but they are subclasses.
Or is there another problem?
Edit:
Second question:
Is there a possibility to duplicate a shortcut and copy that in a second folder?
Thanks!
Tricky question, and the answer should be easy to find one you understand what is the difference between those two ‘folders’:
http://www.lightninglauncher.com/scripting/reference/api/reference/net/pierrox/lightning_launcher/script/api/Container.html
and
http://www.lightninglauncher.com/scripting/reference/api/reference/net/pierrox/lightning_launcher/script/api/Folder.html
I’m going to let you find the answer yourself, I think you may like a hint better than the direct answer. But if I’m wrong and you really want the plain answer say so and I’ll happily provide it.
About that second question, you have
Item Container#cloneItem(Item item)
that duplicates any item. Call that and then move the duplicated.
It’s all in the help..
.I didn’t expect a folder to be a subclass of shortcut.
Calling getContainer helped. Now I just get another error with the return value, but I believe I can find the solution myself.
Thanks for the push!
Maybe you can help me one more time?
I’ve updated my code to this and checked the api-reference for moveItem, but I keep getting a WrappedNull-Reference exception for object.hashCode for the last line.
I tried several versions, but didn’t find the reason.
Is there any way to debug it?
var desktop = LL.getCurrentDesktop();
var it=LL.getEvent().getItem();
var folder = desktop.getItemByName(“Internet”).getContainer();
it = desktop.moveItem(it, folder);
Thanks in advance!
Additional info: the item is moved into the folder, but I do get the error..
I tried the code, and I can replicate the issue.
I tried using different ways to get both the item and the container, but no luck. Strange how nobody reported it before (it seems that feature isn’t used too much)
I can only call Pierre Hébert to check it once it returns back.
In the meantime, Lukas Morawietz any idea?
Thanks for testing!
I try to build a category system for apps with LLX and Tasker (like Folder Organizer or Jina) because the possibilities are endless 🙂
If I can put something viable together I want to share it with the community.
Can reproduce. Personally, I’ve never used move, as my scripts tend to create all items they require
Lukas Morawietz
How could I avoid using move if I want to do the following?:
I launch the script from an app in a folder or from the app drawer and select categories for it.
Therefore it has to be created in one or several other folders too.
If there is an different approach than cloning and moving I’m all ears.
Thanks!
As a workaround, I’d recommend to catch the exception and ignore it.
Lukas Morawietz Thanks, just tried it and it works like a charm 🙂