Okay, so, essentially, I'm getting user input from an <input> tag and shoving it into a canvas. This is all well and good for one line, but there are some cases where I need whole paragraphs of text. As we are all aware, not every letter is of the same width, which means I can't have multiple <input> tags with a maxlength attribute. It's also jarring to have multiple input tags. Long story short: Is there any way to put PARAGRAPH textboxes into a HTML5 canvas element?
- 1Check out : travisberry.com/2011/05/write-text-anywhere-with-html5-canvas to get the idea. I think if you customise it to an extend, it will serve your purpose.Roy M J– Roy M J2013-08-26 10:57:07 +00:00Commented Aug 26, 2013 at 10:57
- possible duplicate of Text wrap in a <canvas> elementrlemon– rlemon2013-08-26 11:01:35 +00:00Commented Aug 26, 2013 at 11:01
- 1Why you don't use textarea for multiline input?Ron van der Heijden– Ron van der Heijden2013-08-26 11:01:43 +00:00Commented Aug 26, 2013 at 11:01
Add a comment |
1 Answer
Why can't you go ahead and use a textarea to get multiline handling?
<textarea name="myTextArea" cols="30" rows="5" /> 3 Comments
rlemon
The issue I assume is translating it to canvas.
Doge
Yes, the issue is translating to canvas. Also, it doesn't matter if the input tag itself can't linebreak, the issue is that fillText() only support a single line, and not, say, a paragraph.
Sunny R Gupta
You can use a custom solution for that, LINK