我需要知道文本指针(闪烁线)在 textctrl 中的位置。我还想知道是否可以获得指针所在的整行,或者我是否只需编写代码即可从指针位置获取当前行。
问问题
2948 次
2 回答
2
您可以使用GetInsertionPoint()
来查找光标的当前位置。您可以使用:len( self.LogWindow.GetRange( 0, self.LogWindow.GetInsertionPoint() ).split("\n") )
获取行号本身。
然后您可以使用:
GetLineText()
获取整行文本...
所以:
curPos = self.LogWindow.GetInsertionPoint
lineNum = self.LogWindow.GetRange( 0, self.LogWindow.GetInsertionPoint() ).split("\n")
lineText = self.LogWindow.GetLineText(lineNum)
在理论上应该有效......?
于 2011-08-17T15:41:21.127 回答
1
您可以使用PositionToXY()
来找出给定插入点的行号,而不是寻找或计数\n
s。
lineNum = self.LogWindow.PositionToXY(curPos)[1] # lineNum is the y coord from PosToXY()
于 2011-08-27T13:02:24.947 回答