How to tell input method editor the customize caret/cursor position

Hi, all.
I’m working on a screenplay editor written by wxPython. The editor has an editing area for users to edit their scripts.

The edit area is manually painted, using a class derived from wx.Control. And the caret is also manually painted. The control catches every editing event(such as EVT_CHAR) and calculates the position of caret and paints it.

The problem is, the editor is for Chinese user (the control calls evt.GetUnicodeKey rather than evt.GetKeyCode from EVT_CHAR event), and when users input the content, they would always use a INPUT METHOD EDITOR. The input method editor would show a selecting frame to display which Chinese character would be entered. If I use origin text input area such as wx.TextCtrl, the selecting frame would show correctly. Because it KNOWS where it should be. By default, the selecting frame would follow the caret, and input method editor can get the position of the caret, if I used origin wx.TextCtrl. But if I draw the caret manually, the selecting frame CANNOT get it’s position, and would show at the bottom of the computer screen.

My question is, is there any way to tell the input method editor the position of the selecting frame, just like what wx.TextCtrl did? I know it may different under mac or windows. The information for any of the platform is welcome. Hope I described clearly. Thank you very much.