Small script that lets you change the Z order of the items in a container from a custom dialog.
Small script that lets you change the Z order of the items in a container from a custom dialog.
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.
]]>
< ![CDATA[
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
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();
}
]]>
< ![CDATA[
Drag’n’drop would be ultimately effective here. Dunno how to do that though. Anyway cool tool
]]>
< ![CDATA[
That’s the first thing I tried to do, but you need custom…all (you need to catch the events and override them)
It is possible, but this is way easier and works 😀
]]>
< ![CDATA[
Interesting idea and script.
Even with plain Java, these “Drag Sort ListView” are not the simplest views to use. But that could be an alternative to the current up/down/top/bottom buttons, or at least it could complement them.
]]>
< ![CDATA[
Or maybe also implement the drag list in the items hierarchy list.
Oh, now I mention that.
In that hierarchy list, the items are displayed from bottom to top, I mean the first item is the ZBottom one (the opposite of this script)
This also makes that the latest shortcut added is always the last one in the list. Maybe you should consider reverse the order.
]]>
< ![CDATA[
Interestingly I was thinking at something related (not with z-order, but with the overall idea). Something is really bothering me since a long time (literally since years): the lack of “immediate” modification control. You almost always need to visit the settings screen to change item properties. I was thinking at using the menu, or some on screen panel, to rapidly change items options. For instance, when editing an item there could be a small panel somewhere to edit often used properties such as font size, colors, etc. Together with multi selection (that I always push back for later…) this would really make editing faster. Since the space is limited, on screen options may be the most used ones based on the user activity, I don’t know, but there is something to improve here.
Being able to drag items directly in the menu is a very good idea: visual, fast and intuitive. More generally the menu could be a more dynamic tool, not only a static list of “shortcuts”.
]]>