Detect text at a certain position

edited September 2015 in Programming Questions

Hello, I am trying to program an e-book simulator with the capability to play audio files. What the program is supposed to do is that when the user hover the mouse over certain text, the audio file will then play. However, from what i have learnt, processing prints text as images and so far I have not come across any function that will allow me to detect the text where the mouse is at to play the audio file.

Am I missing out on something or is there any possible work around this issue that I did not think of? Would really appreciate any form of help.

Thank you!

Tagged:

Answers

  • edited September 2015

    According to text()'s reference: https://Processing.org/reference/text_.html
    using the following overloaded signature: text(str, x1, y1, x2, y2)
    we can restrict the passed String to rendered to a specific area in the canvas.
    From there, it's easy to check whether mouseX & mouseY coords would be hovering over that area. *-:)

Sign In or Register to comment.