mirosz
mirosz

Reputation: 417

Kineticjs - Is there a way to highlight selected text?

I'd like to be able to select text and highlight selected text on a button click. I know I could use Jquery or Html5 'mark' but I'm drawing on a Pdf document so I can't really use it. Any ideas? Thanks

Upvotes: 0

Views: 193

Answers (1)

markE
markE

Reputation: 105035

Since you asked for any ideas...

Here's a very rough outline of how to select & highlight Kinetic text.

  • Create a background layer to hold text highlights.
  • (highlights are just filled rects drawn under selected text fragments).
  • Create a foreground text layer to hold the actual text.
  • Monitor mouse clicks to determine where a user clicks (where they desire selecting).
  • Use context.measureText to determine which text is being selected by the user and draw a highlight rectangle on the background layer under the text to be highlighted.

Upvotes: 1

Related Questions