0
我在Gtk固定項目上移動控件時遇到了問題,代碼抖動移動,它通常很慢。我試圖找到適當的方法來做到這一點,但都顯示了相同的結果。用Gtk鼠標移動控件
我認爲該代碼相關的是:
view.button_press_event.connect((bp) => {
view.set_data("in_motion", true);
int pointX = 0; int pointY = 0;
fixed.get_pointer(out pointX, out pointY);
int origX = 0; int origY = 0;
view.translate_coordinates(fixed, 0,0, out origX, out origY);
view.set_data("startx", origX + origX);
view.set_data("starty", origY + origY);
view.set_data("startsx", pointX);
view.set_data("startsy", pointY);
view.is_focus = true;
view.has_focus = true;
return false;
});
view.button_release_event.connect((bp) => {
view.set_data("in_motion", false);
return false;
});
view.motion_notify_event.connect((me) => {
// TODO: Make this less glitchy somehow
if(view.get_data<bool>("in_motion") == true){
int x = view.get_data<int>("startx") + (int)me.x - view.get_data<int>("startsx");
int y = view.get_data<int>("starty") + (int)me.y - view.get_data<int>("startsy");
((Fixed)view.parent).move(view, x,y);
}
return false;
});
(其餘是https://github.com/kennydude/diagramatic/blob/master/diagram.vala)