0
我創建了一個XNA項目,並試圖執行Neoforce Library,但我無法觸發Button.Click
事件。Neoforce事件處理程序沒有觸發
這裏是我的代碼:
button = new Button(manager);
button.Init();
this.button.Click += new TomShane.Neoforce.Controls.EventHandler(this.button_Click);
button.Text = "Sign In";
button.Width = 72;
button.Height = 24;
button.Left = (main.ClientWidth/2) - (button.Width/2);
button.Top = main.ClientHeight - button.Height - 8;
button.Anchor = Anchors.Bottom;
button.Parent = main;
button.Visible = true;
manager.Add(button);
main.Add(button, true);
我的事件的代碼是:
void button_Click(object sender, TomShane.Neoforce.Controls.EventArgs e) {
System.Console.Out.WriteLine("Button Clicked");
}
一切都顯示正常,但是該事件將根本不會觸發。
我想你必須檢查你的更新功能是否被點擊。 –
您是否試圖查看是否有任何其他事件,例如MouseOver,MouseOut等?你爲什麼用'this.button'而不是'button'?這些可能是2個不同的對象。 – Cyral
此外,當您將鼠標懸停在按鈕上時,您是否看到輕微的光暈?確保從更新方法調用'base.Update(gameTime)'來更新Neoforce。 (假設你從'Application'繼承) – Cyral