Feb 17, 2012 at 12:40 PM

I am having trouble with the 2D buttons. For some reason they show up don't work. I can not click on them. Any idea?

her is the code i have for the button

PauseFrame = new G2DPanel();
            PauseFrame.Bounds = new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            PauseFrame.Border = GoblinEnums.BorderFactory.LineBorder;
            PauseFrame.Transparency = 0.98f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)
            PauseFrame.BackgroundColor = Color.Black;

 G2DButton Reset = new G2DButton("Reset");
            Reset.TextFont = font;
            Reset.Bounds = new Rectangle((graphics.PreferredBackBufferWidth / 2), (graphics.PreferredBackBufferHeight - 50), 256, 50);
            Reset.ActionPerformedEvent += new ActionPerformed(HandleResetActionsPerformed);


        private void HandleResetActionsPerformed(object source)
            //do something

Feb 17, 2012 at 7:26 PM

Which version of Goblin are you using? The code looks correct. Does the button get highlighted if your mouse is over the button?


Feb 21, 2012 at 10:50 AM

i am using 3.6 

no it doesnt get highlighted. 

Feb 21, 2012 at 3:27 PM

Tutorial 3 works fine, right? If you're not seeing the highlight, it's most likely your app is not receiving the mouse move event for some reason. You probably want to check if your XNA receives mouse event using the XNA's mouse states.


Feb 28, 2012 at 8:14 PM

well i figured it out. it was a strange problem. the problem was with the Content. I have a timer class that counts down from some number. For some reason I made it inherit from XNA game class. So it had its own Content. And when I created a new instance of this Timer in my game, it caused the buttons to act weird.