Re: [Flashcoders] Caret position coords
Except getTextExtent() is deprecated with no replacement since 8 O_o Why is that? - Andreas Kalle Thyselius, inlovewith wrote: i remember doing this a few years ago, using — a loop (filling the textfield) and autoSize=true to determine if there was a line break (you could determine this in other ways) — and if _height old_height in the loop, do — letterCurrentY += LINE_HEIGHT then use getTextExtent() to get _x. i remember there was some margins and stuff inside the text field to take into account, but it worked. the problem is it can be hard to find out the constant LINE_HEIGHT. good luck, kalle On 1/2/06, Michael Bedar [EMAIL PROTECTED] wrote: To answer the original question - there is no direct way to do this, although you can use the text-extent to get the x offset of the caret fairly easily in a single line textfield. On Jan 2, 2006, at 9:47 AM, Andreas Rønning wrote: Is there a decent way of getting the _x / _y position of a caret in a text box? Somehow compare the x/y of the textfield with the caret index..? Have a hard time getting an exact value from this. - Andreas ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- inlovewith.com inlovewith ltd. kalle thyselius linnégatan 76, stockholm, sweden + 46 707 602 600 inlovewith you ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Caret position coords
Is there a decent way of getting the _x / _y position of a caret in a text box? Somehow compare the x/y of the textfield with the caret index..? Have a hard time getting an exact value from this. - Andreas ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Caret position coords
Easy... get the x,y in characters of the memo function getCharacterPosition( aMemo: TMemo ): TPoint begin Result.X := LongRec( SendMessage( aMemo.Handle, EM_GETSEL, 0, 0 ) ).Hi; Result.Y := SendMessage( aMemo.Handle, EM_LINEFROMCHAR, Result.X, 0 ); Result.X := Result.X - SendMessage(aMemo.Handle, EM_LINEINDEX, -1, 0); return Result; end; and get the x,y in pixels of the memo function getCharPositionInPixels( aMemo: TMemo ): TPoint var result: TPoint; begin result := aMemo.Perform( EM_POSFROMCHAR, WPARAM(@result), aMemo.SelStart); return result; end Not sure if the code is error free, though but are these api messages ;-) Yours, Weyert de Boer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Caret position coords
Ooh, this is the flashcoders mailing list. This code is useless! sorry. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Caret position coords
To answer the original question - there is no direct way to do this, although you can use the text-extent to get the x offset of the caret fairly easily in a single line textfield. On Jan 2, 2006, at 9:47 AM, Andreas Rønning wrote: Is there a decent way of getting the _x / _y position of a caret in a text box? Somehow compare the x/y of the textfield with the caret index..? Have a hard time getting an exact value from this. - Andreas ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Caret position coords
i remember doing this a few years ago, using — a loop (filling the textfield) and autoSize=true to determine if there was a line break (you could determine this in other ways) — and if _height old_height in the loop, do — letterCurrentY += LINE_HEIGHT then use getTextExtent() to get _x. i remember there was some margins and stuff inside the text field to take into account, but it worked. the problem is it can be hard to find out the constant LINE_HEIGHT. good luck, kalle On 1/2/06, Michael Bedar [EMAIL PROTECTED] wrote: To answer the original question - there is no direct way to do this, although you can use the text-extent to get the x offset of the caret fairly easily in a single line textfield. On Jan 2, 2006, at 9:47 AM, Andreas Rønning wrote: Is there a decent way of getting the _x / _y position of a caret in a text box? Somehow compare the x/y of the textfield with the caret index..? Have a hard time getting an exact value from this. - Andreas ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- inlovewith.com inlovewith ltd. kalle thyselius linnégatan 76, stockholm, sweden + 46 707 602 600 inlovewith you ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Caret position coords
Whoa - dude, is that MFC or something? Alias On 1/2/06, Weyert de Boer [EMAIL PROTECTED] wrote: Easy... get the x,y in characters of the memo function getCharacterPosition( aMemo: TMemo ): TPoint begin Result.X := LongRec( SendMessage( aMemo.Handle, EM_GETSEL, 0, 0 ) ).Hi; Result.Y := SendMessage( aMemo.Handle, EM_LINEFROMCHAR, Result.X, 0 ); Result.X := Result.X - SendMessage(aMemo.Handle, EM_LINEINDEX, -1, 0); return Result; end; and get the x,y in pixels of the memo function getCharPositionInPixels( aMemo: TMemo ): TPoint var result: TPoint; begin result := aMemo.Perform( EM_POSFROMCHAR, WPARAM(@result), aMemo.SelStart); return result; end Not sure if the code is error free, though but are these api messages ;-) Yours, Weyert de Boer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders