User Tools

Site Tools


script_change_zindex

====== About the script ====== * Purpose : Small script that lets you change the Z order of the items in a container from a custom dialog. * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/u/1/105066926163073195690/posts/FuBhf8EwF5T (with video) ====== How to use the script ====== Instructions: Run the script from a container. The list of all the items in that container will be shown (type+label+name). The first item of the list is the top most one. The last item the bottom most one. Choose two of them to exchange their Z order. Repeat. Click exit to exit. Note: I tested it some few times(in fact I had the idea less than two hours ago) and it works, but as usual maybe it don't work in some specific situations. Anyway the script only change the Z order, nothing more. ====== Script code ====== <sxh javascript> LL.bindClass("android.app.AlertDialog"); LL.bindClass("android.content.DialogInterface"); run(LL.getEvent().getContainer()); function run(cont){ var items=cont.getItems(); var names=[]; var ids=[]; for(var t=0;t<items.getLength();++t){ var it=items.getAt(t); names[t]=it.getType()+" : "+it.getLabel()+" ["+it.getName()+"]"; ids[t]=it.getId(); } names=names.reverse(); ids=ids.reverse(); var check=-1; var builder=new AlertDialog.Builder(LL.getContext()); builder.setTitle("Select two to echange"); builder.setMultiChoiceItems(names,null,new DialogInterface.OnMultiChoiceClickListener(){onClick:function(dialog,which,checked){ //function var id=ids[which]; if(id==check){check=-1;return;} if(check==-1){check=id;return;} //else, echange check and id var a=cont.getItemZIndex(check); var b=cont.getItemZIndex(id); cont.setItemZIndex(id,a); cont.setItemZIndex(check,b); run(cont); dialog.dismiss(); }}); builder.setPositiveButton("Exit",null); builder.create().show(); } </sxh>

script_change_zindex.txt · Last modified: 2015/03/17 21:31 by trianguloy