tags:

views:

26

answers:

1

Hi I wrote a script with the "undotext" widget, and I'm looking for a way to get the line index of the palce where the mouse cursor is standing.

and similarly when the user has select part of the line.

+1  A: 

To get the current location of the mouse cursor in text coordinates (not just x,y) you need to do either this:

$txt->index("current");

or this (where $x and $y give the mouse cursor location relative to the text widget):

$txt->index("@$x,$y");

The first is definitely more convenient, but the second is needed if you're in the middle of a drag (the current mark isn't updated while any mouse button is down).

Donal Fellows