1

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?

Doge
  • 347
  • 1
  • 4
  • 13
  • 1
    Check out : http://www.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 Aug 26 '13 at 10:57
  • possible duplicate of [Text wrap in a element](http://stackoverflow.com/questions/2936112/text-wrap-in-a-canvas-element) – rlemon Aug 26 '13 at 11:01
  • 1
    Why you don't use [textarea](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea) for multiline input? – Ron van der Heijden Aug 26 '13 at 11:01

1 Answers1

1

Why can't you go ahead and use a textarea to get multiline handling?

<textarea name="myTextArea" cols="30" rows="5" />
Sunny R Gupta
  • 5,026
  • 1
  • 31
  • 40
  • 2
    The issue I assume is translating it to canvas. – rlemon Aug 26 '13 at 21:57
  • 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. – Doge Aug 27 '13 at 00:40
  • You can use a custom solution for that, [LINK](http://stackoverflow.com/a/7974313/1477051) – Sunny R Gupta Aug 27 '13 at 04:30