Gtk 获取树视图中指针的行/单元格

Gtk 获取树视图中指针的行/单元格,gtk,gtk3,Gtk,Gtk3,如何在GtkTreeView中找到光标所在的行或单元格 我试过: screen, _ := tv.Widget.GetScreen() display, _ := screen.GetDisplay() seat, _ := display.GetDefaultSeat() device, _ := seat.GetPointer() window, _ := tv.GetWindow() _, x, y, _ := window.GetDevicePosition(device) tx, ty

如何在
GtkTreeView
中找到光标所在的行或单元格

我试过:

screen, _ := tv.Widget.GetScreen()
display, _ := screen.GetDisplay()
seat, _ := display.GetDefaultSeat()
device, _ := seat.GetPointer()
window, _ := tv.GetWindow()
_, x, y, _ := window.GetDevicePosition(device)
tx, ty := -1, -1
tv.ConvertBinWindowToTreeCoords(x, y, &tx, &ty)
_, _, row, _, rowExists := tv.GetPathAtPos(tx, ty)
ConvertBinWindowToTreeCoords
将设备位置(似乎合理)转换为巨大的负数(!?)。所有这些位置/坐标周围的文档都非常模糊,无法确定它们确切使用的坐标(例如,如何与ScrollWindows交互)。 即使是
Coords
Pos
Position
之间的术语在我看来也很假


有人知道这是怎么回事吗?

结果更简单

motion := gdk.EventMotionNewFromEvent(event)

x, y := motion.MotionVal()

path, _, _, _, rowExists := tv.GetPathAtPos(int(x), int(y))
if !rowExists {
    return true
}

return true
使用
是我的误解,因为它实际上意味着缩进级别。 因此,实际索引保存在
路径中