I seem to have forgotten how to implement LAF on a label
-
This isn't drawing the look and feel:
// create the search bar const var searchBar = Content.addLabel("searchBar", 10, 10); searchBar.set("width", 250); searchBar.set("height", 30); searchBar.set("text", "Search..."); searchBar.set("editable", true); // laf const laf = Content.createLocalLookAndFeel(); searchBar.setLocalLookAndFeel(laf); laf.registerFunction("drawLabel", function(g, obj) { var w = obj.area[2]; var h = obj.area[3]; g.setColour(Colours.white); g.fillRect([0, 0, w, h]); g.setColour(Colours.grey); g.drawRoundedRectangle([0, 0, w, h], 5, 1); var iconSize = 12; var cx = 10; var cy = h / 2; g.setColour(Colours.grey); g.drawEllipse([cx, cy - iconSize / 2, iconSize, iconSize], 1.5); var angle = 45 * Math.PI / 180; var lineLength = 7; var startX = cx + iconSize / 2 * Math.cos(angle); var startY = cy + iconSize / 2 * Math.sin(angle); var endX = startX + lineLength * Math.cos(angle); var endY = startY + lineLength * Math.sin(angle); g.drawLine(startX, endX, startY, endY, 1.5); g.setColour(Colours.black); g.setFont("Arial", 14); var textOffset = 25; g.drawAlignedText(obj.text || "", [textOffset, 0, w - textOffset - 5, h], "left"); });
I'm suspecting the name of the laf function, but I do not see a reference to find what names to use.
-
@VirtualVirgin Labels don't have laf. You need to draw it on the panel behind the label - or just use a panel.
@VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:
but I do not see a reference to find what names to use.
The autocomplete popup contains a full list.
-
@d-healey said in I seem to have forgotten how to implement LAF on a label:
@VirtualVirgin Labels don't have laf. You need to draw it on the panel behind the label - or just use a panel.
@VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:
but I do not see a reference to find what names to use.
The autocomplete popup contains a full list.
These should probably be removed from the Docs then:
Also, maybe I don't know how to use the autocomplete in the way you are referring to it, but it don't get anything when typing in the name argument in the script:
-
@VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:
These should probably be removed from the Docs then:
Yeah I think that's auto-generated.
@VirtualVirgin said in I seem to have forgotten how to implement LAF on a label:
Also, maybe I don't know how to use the autocomplete in the way you are referring to it, but it don't get anything when typing in the name argument in the script:
Start typing register function and when the list pops up it will show all the available functions. If you don't have it set to auto popup then you need to press ESC to open it.
-
@VirtualVirgin You might try CSS on the Label instead: