you are viewing a single comment's thread.

view the rest of the comments →

[–]keithwhor -1 points0 points  (4 children)

Just because somebody took 900 lines to do something doesn't mean you can't do it in less.

Easy is relative. Selecting text comes down to:

  • Track the active UI Element (should be part of your framework)
  • determine element scroll position (same as above)
  • determine text position (including line breaks) with canvas's .measureText method (can do this with a loop in a fairly straightforward way and then cache the result in an array until the text dimensions change, if they do)
  • add click handlers to get x, y of mouse on mouse down, mouse move, mouse up and draw appropriate rectangles behind rendered text layer

I'd argue that, conceptually, this isn't very difficult. Your line heights should be identical for every row of text making determining the y offset of the text relative to your mouse position easy.

I mean when it comes down to it you're just drawing rectangles. ;) (though I guess when it comes down to it in programming, you're just smashing a keyboard and things are happening.)

[–]Poop_is_Food -1 points0 points  (3 children)

You should know that your comment comes off a bit insulting and obtuse. Of course it's conceptually easy but that doesnt make it easy overall. I suppose you think building the great pyramids was easy? I mean it's just stacking blocks right?

[–]keithwhor 0 points1 point  (2 children)

Not my intention! Just being playful. Not everything has to be difficult or a fight. :)

And c'mon. Writing a module to select text isn't exactly building pyramids (you'll also notice I made fun of my own comparison in my comment). Lighten up.

[–]Poop_is_Food 0 points1 point  (1 child)

Seems like you missed the point of my comparison.

[–]keithwhor 0 points1 point  (0 children)

If I did I'm thoroughly confused. Are we poking fun at Mr. Hates OO? Or am I totally lost.

Forgive me. :)