Hi All

Arthur van Leeuwen wrote:
> On 18-feb-2007, at 18:23, Mads Lindstrøm wrote:
> 
> > Hi all
> >
> > I have created a text-control and I want to know which character the
> > mouse is hovering over. Getting the mouse position is easy enough.
> > However converting the mouse position to a character index (into the
> > text-control's text) seems very difficult.
> >
> > Anybody knows how to go from mouse position to character index?
> 
> First, you need to get a hold of the TextCtrl. Then on that
> you can use textCtrlPositionToXY to get the x- and y- coordinate of the
> character in character increments. textCtrlPositionToXY is in WXCore.

textCtrlPositionToXY get the character position. That is, in the text:

ab
c
def

a, b, c, d, e, and f will have character positions (0,0), (1,0), (0,1),
(0,2), (1,2), and (2,2) respectively.

When I wrote the mouse position, I was referring to the bitmap position
on the canvas (on which the characters are drawn) - I should have been a
bit more precise there. I get this position by capturing mouse events
by:

   set textCtrl [ on mouse := ... ]

> 
> One tip: try searching the wxWidgets docs first when trying to figure
> out how to do stuff. For me it tends to lead me to the result quicker  
> than
> perusing just the wxHaskell docs.
Good point.

> 
> With regards, Arthur van Leeuwen.
> 

Kind regards,

Mads Lindstrøm



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
wxhaskell-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users

Reply via email to