Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Highlight Characters in Multiline Text

Author
Message
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 22nd Nov 2013 02:44
I've been trying to think of the most efficient way to highlight characters and words on mouseover, in a large multiline textarea.

Not quite sure what the most efficient way to go about it would be. What do folks think? It would be nice if there were a GetCharHitTest() to go with the GetTextHitTest().
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 22nd Nov 2013 04:32
If the font used is a fixed font, you can probably calculate the position in the text area base on mouse location in relation to to the start of the text, if the GetTextHitTest indicates that the mouse is within the box. Then your only options are to change the color of hte text, but that is only done one character at a time. And you'd have to keep track of a lot of stuff to make sure you unhighlighted the text when the mouse move somewhere else.

I can sort of see the code in my head, but it would take a while to put it together (and I don't really have time for that right now).

Another way might be to have a sprite with a lightish color and very low alpha and resize and position it over highlighted areas.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 22nd Nov 2013 04:42
Umph, yes seeing it all in my head in a way that isn't messy is what I seem to have a block on.

I'm just trying to set up word highlighting on mouseover in the end, so you can interact with them.

Even with a fixed font, calculating the # of characters using the width of each line it seems cannot be simply done? with a multiline text area, you can only get the length of the longest line GetTextTotalWidth( iTextIndex ) -- other lines will be other character amounts.

Login to post a reply

Server time is: 2024-05-20 09:18:10
Your offset time is: 2024-05-20 09:18:10