简体   繁体   中英

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.

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. Like so:

manager.Update(gameTime);

Thanks to Cyral, for giving me the idea to check for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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