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
不会被调用(通过放置一个断点检查那里)。
缺失的部分是什么?