I am pulling my hair and cannot figure out how to make a TEXT into BUTTON.
I know how to create a button like this:
Code: Select all
buttonHelp = win.add("button", [20, 365, 240, 395], "Help",);
Is it possible?
Appreciate your time.
Moderator: Paul Tuersley
Code: Select all
buttonHelp = win.add("button", [20, 365, 240, 395], "Help",);
Code: Select all
(function(ooo){
(ooo instanceof Panel) || (ooo=new Window("palette"));
ooo.onResizing = ooo.onResize = function(){this.layout.resize();};
var myText = ooo.add("panel{margins: 2}").add("statictext{text: 'Come and see!'}");
myText.addEventListener("mouseover", myHandleFunc);
myText.addEventListener("mouseout", myHandleFunc);
myText.addEventListener("mousedown", myHandleFunc);
myText.addEventListener("mouseup", myHandleFunc);
function myHandleFunc(ev){
var t = ev.target, color, gfx;
if (t instanceof StaticText){
switch(ev.type){
case "mousedown": color = [1,1,1]; break;
case "mouseover": color = [0.5,0.5,0.5]; break;
case "mouseup": color = [0.5,0.5,0.5]; break;
default : color = [0,0,0];
};
gfx = t.graphics;
gfx.foregroundColor = gfx.newPen(gfx.PenType.SOLID_COLOR, color, 1);
};
return;
};
(ooo instanceof Panel) ? ooo.layout.layout(true) : ooo.show();
return;
})(this);