在 Gtk.Entry 的光标处显示 Gtk.Popover
Show Gtk.Popover at cursor of Gtk.Entry
我想在Gtk.Entry
的光标位置显示Gtk.Popover
。我只能添加相对于条目本身的弹出窗口,但 Gtk.Popover
每次都出现在 Gtk.Entry
的中心。
有什么方法可以获取 Gtk.Entry
光标的位置并在该位置创建弹出窗口?
您应该通过使用 Gtk.Popover.relative_to
; then you can use Gtk.Popover.pointing_to
and the rectangle with the location of the cursor. To get that, use Gtk.Entry.cursor_position
以字符形式检索光标索引并将其转换为 Pango.Layout 内的位置来设置弹出窗口相对的小部件=13=] 小部件;如果允许条目滚动,您还应该获取 Gtk.Entry.scroll_offset
并从 Pango 返回的坐标中减去它。
我想在Gtk.Entry
的光标位置显示Gtk.Popover
。我只能添加相对于条目本身的弹出窗口,但 Gtk.Popover
每次都出现在 Gtk.Entry
的中心。
有什么方法可以获取 Gtk.Entry
光标的位置并在该位置创建弹出窗口?
您应该通过使用 Gtk.Popover.relative_to
; then you can use Gtk.Popover.pointing_to
and the rectangle with the location of the cursor. To get that, use Gtk.Entry.cursor_position
以字符形式检索光标索引并将其转换为 Pango.Layout 内的位置来设置弹出窗口相对的小部件=13=] 小部件;如果允许条目滚动,您还应该获取 Gtk.Entry.scroll_offset
并从 Pango 返回的坐标中减去它。