How do I get the height of each line, or the total number of lines, of a Text object?

0 favourites
  • 1 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • I am trying to detect which line of text a user clicks on in a Text object. To do this, I start by calculating the Y position of the click relative to the Text object's origin, but the problem is then how to convert this Y value to a line number. In order to do this, I would have to get either the height of each line, or the total number of lines of the text (including automatic wrapping done by the Text object) and then calculate the height of each line from the TextHeight.

    Although I haven't tried, it seems that the CharacterHeight expression could have been used for this purpose, if I had used a SpriteFont object instead. However, I prefer using the Text object because of its better unicode support, and unfortunately the CharacterHeight expression is missing from the Text object.

    Is there a way of accessing the height of each line, or the number of lines of (wrapped) text, of a Text object? Perhaps I am missing something obvious here?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)