0
我正在試驗一下monodevelop/c#/ gdk,我能夠創建一個窗口,並且正確地處理了這個expose事件的DrawingArea
。爲什麼不能獲得`ButtonPressEvent`
然而,鼠標放下事件並沒有調度,我不明白爲什麼。代表們已經成立了由GUI設計器自動生成代碼:
this.da.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnDAExposeEvent);
this.da.ButtonPressEvent += new global::Gtk.ButtonPressEventHandler (this.OnDAButtonPressEvent);
this.da.MotionNotifyEvent += new global::Gtk.MotionNotifyEventHandler (this.OnDAMotionNotifyEvent);
,這是我的初始化代碼:
public MainWindow() : base (Gtk.WindowType.Toplevel)
{
Build();
Gdk.Color col = new Gdk.Color();
col.Red = col.Green = col.Blue = 0x8888;
da.ModifyBg(StateType.Normal, col);
var p = "wr/wn/wb/wq/wk/wp/br/bn/bb/bq/bk/bp".Split ('/');
for (int i = 0; i < p.Length; i++) {
pieces[p[i]] = new ImageSurface("/home/agriffini/x/chessboard/i" + p [i] + ".png");
}
da.Events |= (Gdk.EventMask.ButtonPressMask
| Gdk.EventMask.ButtonReleaseMask
| Gdk.EventMask.KeyPressMask
| Gdk.EventMask.PointerMotionMask);
}
但是該處理函數OnDAButtonPressEvent
不會被調用(通過放置一個斷點檢查那裏)。
缺失的部分是什麼?