經過一段時間的討論後,似乎與Winforms不同(至少沒有和他們一起玩過),GTK似乎將關鍵事件傳遞給widget樹,所以,下面的代碼工作得很好,重點關注在窗口小部件的任何:
public class ConnectWindow : GTK.Window
{
public ConnectWindow(Window parent)
: base(WindowType.Toplevel)
{
this.Parent = parent;
_init();
}
private void _init()
{
this.Title = "Connect to...";
this.Modal = true;
this.WindowPosition = WindowPosition.Center;
this.KeyReleaseEvent += ConnectWindow_KeyReleaseEvent;
// [snip] other initialisation stuff
}
void ConnectWindow_KeyReleaseEvent(object o, KeyReleaseEventArgs args)
{
if (args.Event.Key == Gdk.Key.Escape)
{
btnCancel.Activate();
}
}
}
請閱讀編輯我只是把......我瞭解的WinForms的作品,我需要在GTK#相同的功能,但(這是我使用的是什麼)。 – 2009-06-12 10:20:42