Selecting textparts in a textbox

Started by loominous, Thu 21/07/2005 03:42:03

Previous topic - Next topic

loominous

Is it possible to select text as one would in a texteditor? My goal is to enable the player to select any text from the game (and save it), so cumbersome workarounds with clickable invisible objects or such isn't really an option.

Much obliged for any solution.

(To be completely clear, the player should be able to select single words, so just saving individual lines wouldn't do it)
Looking for a writer

Gilbert

Not directly unfortunately, that will involve some scriptings.

loominous

Could you elaborate somewhat? I'm not asking for the script, just an idea of how it could be made, functions to be used etc.

Atm I have no idea how to get the game to respond to clicks on text.

Thanks.
Looking for a writer

Gilbert

#3
Well since it's quite hard to explain, I mucked up some crappy demo:
Grab here
which I worked hard using trial-and-error to get to work (sort of working anyway), it's crapily pieced together so there might be simpler solutions (now it's more like a hack, which requires a fixed width font).

(Compile it with V2.62, not that I don't know how to script in V2.7, I just don't use V2.7+)

Just type something, drag over the text to highlight, release button to see what is copied.

loominous

My, my, that's really good of you to take the time, thanks a bunch!

As I understand it the script only works with monospaced fonts, so I'm thinking of a solution for proportional ones, since the game depends on them.

The only way I've come up with so far would be to find out the width of each character and then have the script add those values up to figure out the current mouselocation.

Does any easier solution strike anyone?
Looking for a writer

Gilbert

I think there're no easy way, if your font is not fixed width it will be much more complex. Afterall AGS was not originally designed to have that many functionalities in that field.

GarageGothic

#6
I don't think it would be much more difficult just using GetTextWidth, which would allow you to use any font. The main problem seems to be the spacing (or rather, not being able to use spaces for alignment), so you might see the highlighted text slightly misaligned.

SMF spam blocked by CleanTalk