我在 OSX 上使用 VS Code,并嘗試在我的按鈕按下事件中向用戶顯示一個對話框。下面的代碼是我所擁有的,但是當按下按鈕時,對話框永遠不會顯示。 public static void Main(string[] args) { Application.Init(); MainWindow win = new MainWindow(); Button btnClick = new Button("Button"); win.Add(btnClick); btnClick.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressHandler); btnClick.Visible = true; win.Show(); Application.Run(); } private static void ButtonPressHandler(object obj, ButtonPressEventArgs args) { MessageDialog md = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, "You pressed the button!"); md.Run(); md.Destroy(); }
1 回答

墨色風雨
TA貢獻1853條經驗 獲得超6個贊
我認為您需要 btnClick.Clicked 而不是 btnClick.ButtonPressEvent。甚至似乎沒有 ButtonPressEvent 成員。請參閱http://docs.go-mono.com/?link=T%3aGtk.Button
- 1 回答
- 0 關注
- 94 瀏覽
添加回答
舉報
0/150
提交
取消