我有這樣的代碼:當按下按鍵最爲什麼按下回車鍵不會在我的Gtk.Entry中觸發KeyPressEvent?
...
entry.KeyPressEvent += EntryKeyPressEvent;
...
}
void EntryKeyPressEvent(object o, KeyPressEventArgs args)
{
Console.WriteLine("DEBUG: KeyValue: " + args.Event.KeyValue);
...
}
EntryKeyPressEvent被調用,而不是返回鍵。爲什麼是這樣?
編輯:當大多數按鍵被按下時,它實際上不會被調用。有些人稱它爲(例如,上升,下降,逃跑),但大多數不會(例如,任何字母鍵,返回)。
僅供參考,我想端口PyGTK的代碼看起來像這樣:
...
entry.connect('key_press_event', self.entry_key_pressed)
...
def entry_key_pressed(self, widget, event):
...
啊!所以Gtk.Entry正在吃那些按鍵事件!奇怪的是,它沒有在Python中這樣做。 – RAOF 2009-11-09 03:37:44