Search code examples
positionwxpythoncaretrichtextctrl

Get caret position in pixel in RichtextCtrl


How we get caret position in x,y pixel to window. i tried following method but it only gives column and row for given position.

 windowCaretPosition = self.__editor.PositionToXY(self.__editor.GetInsertionPoint())

it returns tuple with column and row. but i need x,y point show to context menu near caret when key up


Solution

  • When the user clicks on the position where you want to show the context menu, get x and y from the event:

    def _OnClick(self, evt):
        x, y = evt.GetX(), evt.GetY()