0 Favourites

Clickable individual words within a Text object

  • Hi there.

    Is it possible to make individual words within a text object clickable? -And if so, how would I go about this?

    I'm working on a project that'll have large amounts of text read from XML files and I need to be able to make specific words interactable.

    I've yet to find a way to be able to do this.

    Any ideas?

    Thanks.

  • Or, failing this, does anyone have any ideas as to the best way to achieve a similar effect?

    I suppose one could, in theory, have every word within an XML doc load into a separate Text object.

    But this seems rather inefficient when dealing with large amounts of text.

    Is there a better way?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You might want to look at :

  • [quote:277ztqzp]You might want to look at :

    ... spritefont

    How does the use of a Sprite Font make it any easier to interact with specific parts of text content within an object?

    Sorry, I'm not quite following.

  • You know the exact lenght of the words. If you know the lenght, you know where they are.

    Some math and good logic will bring you there.

    Unless you expected a capx dooing it all for you, ofcours. Then you are still nowhere. Sorry.

  • [quote:1wmfh7nu]You know the exact lenght of the words. If you know the lenght, you know where they are.

    Some math and good logic will bring you there.

    True.

    But, firstly, I'd be somewhat concerned about relying upon absolute positioning, as apposed to addressing the text content itself, as it wouldn't allow for flexibilty in layout & font formatting.

    Addressing via position would also means one would have to separately refer to every instance of a particular word, as apposed to once per unique word.

    I'd be working with hundreds of thousands of words in XML docs.

    So it only becomes feasible if I can automate the process of making words addressible, (ideally by text content rather that relying upon absolute positioning.)

    [quote:1wmfh7nu]

    Unless you expected a capx dooing it all for you, ofcours

    I expected nothing of the sort.

    What would give you that impression?

    I'm merely asking if anyone has any ideas or advice on the subject.

    Is that not what this section of the forum is for?

    Thanks.

  • Regardless of if you use a text object or spritefont, I would imagine parsing out the words of interest, replacing them with blank space of the same length, and putting an object with the former contents in it's place.

    Alternatively, you would create an "imagemap" of sorts, where you identify the words of interest and their x/y coordinates. Spritefont would be superior, as it would be much more reliable to calculate out pixel locations and sizes of characters with expressions.

    The method would use either tokens (simpler, less powerful), or regex (powerful, more complicated)

  • Have you tried when the text object is clicked to determine where the touch/click point is? Then find a formula based on position to determine which word.

    There are fonts where each character is the same size so should be possible.

  • Or assign one spritefont object per word, and create an on trigger condition based on some instance variable of the spritefont object.

  • What is the ultimate goal?

    Dragging selected words arround as sprites, mayby rearrange ?

    Do evalutions on the text content? Should the action return a string ?

  • This example returns a string.

    Need this plugin:

  • Thanks all, that's been really helpful.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)