Pierre Hébert LL 8.1
Pierre Hébert LL 8.1
I set folder as sidebar. In folder is panel with items. When trying to open this folder LL stops. I tried to disable seamles mode x for this panel, by editing it’s properties from hierarchy. But this doesn’t solve the issue. I moved this panel from folder to desktop. Now folder opens. But after restarting LL can’t use LL anymore. I only got a black screen. I think because of this panel on home desktop
]]>« Pierre Hébert LL 8.1 (Previous Post)
(Next Post) B2 seamless on, panel in edit mode doing something wrong with moving icon. Pierre Hébert »
< ![CDATA[
(12.8.1, 8.1 is two years old 😉 )
I just published an update. It should fix the issue with panel edition / seamless mode. For the black screen after restart, I don’t know.
]]>
< ![CDATA[
Pierre Hébert
Black Screen seems to be an Script issue. Also the stop with the panel. With script deactivated, black Screen is gone. The following script which manipulates the live image starts in the resume event. Function setBadge() or hideBadge() may be the responsible for the issue.
/*MK CBadge.js V. 0.1
script showing badges on Icons.
To set a badge run the Script with parameter “itemID”:”number to schow in badge”.
if Number = 0 then badge will be hidden.
*/
var ev = LL.getEvent();
var myScript = LL.getCurrentScript();
var tagId = “MK CBadge”;
var badgeRadius = 13;
var badgeBackgroundColor = 0xffff0000; //red
var badgeEdgeColor = 0xffffffff; //white
var badgeTextColor = 0xffffffff;
//show and create a badge
//get Data to know which item and number it should be
var ziel = ev.getData();
var target = new Array();
target = ziel.split(“:”);
var item = LL.getItemById(target[0]);
if (item !== null) {
setIScript(item,target[1]);
if (target[1] == 0) {
hideBadge(item);
} else {
setBadge(item,target[1]);
}
//setIScript(item,target[1]);
} else {
Android.makeNewToast(“Fehler: Update von Item (” + target[0] + “) nicht möglich!”, true).show();
}
return;
//set the badge on the desired item.
function setBadge(bitem, bnum) {
//Android.makeNewToast(“setBadge”,true).show();
var dic = null;
try {
dic = bitem.getImage();
} catch (error) {
//alert(error);
//Android.makeNewToast(error,true).show();
dic = null;
}
if (dic !== null) {
var wd = dic.getWidth();
var hg = dic.getHeight();
var ps = bitem.getProperties();
//create a new image for the badged item
var i = LL.createImage(wd, hg);
//get the canvas of the new image
var c = i.draw();
var p = new Paint();
//set the radius for the Badge regarding the icon scale
var cr = badgeRadius * ps.getFloat(“s.iconScale”);
//setting textsize
var ts = cr + 3;
//copy original image of item in new image
c.drawBitmap(dic.getBitmap(), 0, 0, null);
//draw the badge-background
p.setAntiAlias(true);
p.setStyle(Paint.Style.FILL);
p.setColor(badgeBackgroundColor);
c.drawCircle(i.getWidth() – cr, cr, cr – 1, p);
//draw the badge edge
p.setStrokeWidth(2);
p.setColor(badgeEdgeColor);
p.setStyle(Paint.Style.STROKE);
c.drawCircle(i.getWidth() – cr, cr, cr – 2, p);
//draw the number
p.setColor(badgeTextColor);
p.setTextAlign(Paint.Align.CENTER);
p.setTextSize(ts);
p.setStrokeWidth(1);
p.setStyle(Paint.Style.FILL);
c.drawText(bnum, i.getWidth() – cr, cr + (ts / 3), p);
i.update();
//give the item our new image
bitem.setImage(i);
i.save();
}
else {
Android.makeNewToast(“SetBadge dic null”,true).show();
}
return;
}
//hide the badge
function hideBadge(bitem) {
//Android.makeNewToast(“hideBadge”,true).show();
var itag = bitem.getTag(tagId);
var ps = bitem.getProperties();
var data = JSON.parse(itag);
//revert to orignal image
var dic = bitem.getCustomIcon();
//no custom icon set? -> take default icon
if (dic === null) {
dic = bitem.getDefaultIcon();
}
try {
bitem.setImage(dic);
} catch (error) {
//alert(error);
}
ps.edit().setFloat(“s.iconScale”,ps.getFloat(“s.iconScale”)).commit();
return;
}
function setItemTag(bitem, bnum) {
//store the badgenumber in item tag
var data = new Object();
data.badge = bnum;
setIScript(bitem,bnum,false);
bitem.setTag(tagId,JSON.stringify(data));
return;
}
function setIScript(sitem,bnum){
if (bnum==0){
var URS = 0;
var num = “”;
var SCRIPT = null;
} else {
var URS = 35; //RUN_SCRIPT
var num = “:”+bnum;
var SCRIPT = myScript.getId()+”/”+sitem.getId()+num;
}
var ps = sitem.getProperties();
ps.edit().setEventHandler(“i.resumed”, URS, SCRIPT).commit();
return;
}
function clearItemTag(bitem) {
var itag = bitem.getTag();
//var ps = bitem.getProperties();
var data = JSON.parse(itag);
if (data !== null) {
if (data.badge > 0) {
hideBadge(bitem);
}
//var UNSET = 0;
//ps.edit().setEventHandler(“i.resumed”, UNSET, null).commit();
setIScript(bitem,0,false);
//delete the item tag
bitem.setTag(tagId,null);
}
return;
}
]]>
< ![CDATA[
I found what the issue is with the script. It’s not easy to fix. It was somewhat working previously thanks to a… bug. A bug which has been fixed in 12.8b1.
]]>
< ![CDATA[
Has it to do with Image.save()?
Or with LL.runScript()?
Following binding will also not work if $MKB_Mail is true:
if ($MKB_Mail) {
LL.runScript(“MK CBadge”,item.getId()+”:”+$MKB_Mail);
}
return;
]]>
< ![CDATA[
Image.save() : it triggers a reload and a sequence of pause/resume events. Since this script is run in the resume, it loops forever. Previously the resume event wasn’t sent correctly, hence the absence of recursion.
]]>
< ![CDATA[
What is with the binding? Triggers it also a reload and resume events?
]]>
< ![CDATA[
Pierre Hébert
In B3 now the binding brings message “Cannot show start in this context”.
Also Script is stopped with error “start”.
]]>
< ![CDATA[
Forget last comment. I added “alert(start);” for debugging to script. But start is no variable. So error message shows up in the right way.
Binding works with B3 as expected.
]]>
< ![CDATA[
Great!
]]>