This repository has been archived on 2023-09-06. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
py-gtk-notes
Archived
1
0
Fork 0

解决输入法候选框跟随问题

master
yutent 2023-07-31 20:14:01 +08:00
parent 3baf778260
commit 5735427f19
1 changed files with 8 additions and 2 deletions

10
main.py
View File

@ -83,7 +83,10 @@ class WebKitWindow(Gtk.Window):
# self.webview.load_uri("https://benchmark.wkit.fun") # self.webview.load_uri("https://benchmark.wkit.fun")
# 解决输入法候选框跟随问题
im.connect('preedit-started', self.on_preedit_changed)
im.connect('preedit-changed', self.on_preedit_changed) im.connect('preedit-changed', self.on_preedit_changed)
im.connect('preedit-finished', self.on_preedit_changed)
@ -94,9 +97,12 @@ class WebKitWindow(Gtk.Window):
def on_preedit_changed(self, im): def on_preedit_changed(self, im):
print(p) display = Gdk.Display.get_default()
p = display.get_pointer() # 光标位置
x, y = self.get_position() # 窗口位置
im.notify_focus_in() im.notify_focus_in()
im.notify_cursor_area(100, 200, 0,0) im.notify_cursor_area(p.x - x, p.y - y, 0, 0) # 修正输入法跟随