Assuming you just want to place the text on top of the canvas in the html page:
HTML:
<label>Yahoo, I'm on top of canvas??</label> <canvas width="500" height="500" ></canvas>
CSS
canvas { border:1px solid gray; } label { position:absolute; top:20px; left:20px; }
Working demo
<h / "> EDIT:
According to the editing, if you are looking for a solution to select the text inside the canvas, it will be a little painful.
I would suggest using CreateJS . This would make your life a lot easier with your canvas.
Although the library does not provide you with accessible text, it is easier to implement.
Here is a DEMO , how you could create selectable text.
// Text Selector Class function Selector(stage, text) { var select = new createjs.Shape(); function selector(x, y, width, height) { select.graphics.clear().beginFill("#ace") .drawRect(x || 0, y || 0, width || 0, height || 0); } var tuw = text.getMeasuredWidth(); var tuh = text.getMeasuredHeight(); text.addEventListener("mousedown", function (e) { var startX = e.rawX; var onMove = function (e) { if (e.rawX >= text.x && e.rawX <= text.x + tuw) selector(startX, text.y, e.rawX - startX, tuh); }; var onUp = function () { stage.removeEventListener("stagemousemove", onMove); selector(); }; stage.addEventListener("stagemousemove", onMove); stage.addEventListener("stagemouseup", onUp); }); return select; } var stage = new createjs.Stage("shape"); // Text Node var text = new createjs.Text("Hello World"); text.x = 100; text.font = "20px Arial"; text.color = "#ff7700"; text.cursor = "text"; stage.addChild(text); // Attach Selector stage.addChildAt(new Selector(stage, text), 0); // Important stage.enableMouseOver(); setInterval(function () { stage.update(); }, 100);
loxxy source share