简体   繁体   English

Neoforce事件处理程序未触发

[英]Neoforce Event Handler not firing

I have created an XNA project and am trying to implement the Neoforce Library , but I cannot get the Button.Click event to fire. 我创建了一个XNA项目,并尝试实现Neoforce库 ,但无法Button.Click事件。

Here's my code: 这是我的代码:

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);

My event's code is: 我的活动代码是:

void button_Click(object sender, TomShane.Neoforce.Controls.EventArgs e) {
    System.Console.Out.WriteLine("Button Clicked");
}

Everything is displayed fine, however the event will simply not fire. 一切都显示正常,但是该事件不会触发。

In the Update method, you must run the manager Update method. 在Update方法中,您必须运行管理器Update方法。 Like so: 像这样:

manager.Update(gameTime);

Thanks to Cyral, for giving me the idea to check for this. 感谢Cyral,让我有想法进行检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM