• Create Account

Posted 18 December 2012 - 01:14 AM

Try replacing

myButton.Click += new Action(myButton_Click);
with
myButton.Click += myButton_Click;
or
myButton.Click += () => {Console.Write("foo");};

From what I can tell in the MSDN article, the constructor format of Action doesn't do what you're thinking it does. I'll gladly take some correction on that if I didn't search deep enough though.

Sorry, this doesn't work. It doesn't even compile due to syntax errors.

I would track the mouse position and whether or not it's been clicked in the Window class, and then if the position of the cursor is inside of myButton when a click is dispatched call myButton.OnClick().

That was my thought as well. Since you already made a GUI: How did you listen for the mouse? Did you add an own class for this or where did you put it?

Posted 18 December 2012 - 01:14 AM

Try replacing

myButton.Click += new Action(myButton_Click);
with
myButton.Click += myButton_Click;
or
myButton.Click += () => {Console.Write("foo");};

From what I can tell in the MSDN article, the constructor format of Action doesn't do what you're thinking it does. I'll gladly take some correction on that if I didn't search deep enough though.

Sorry, this doesn't work. It doesn't even compile due to syntax errors.

I would track the mouse position and whether or not it's been clicked in the Window class, and then if the position of the cursor is inside of myButton when a click is dispatched call myButton.OnClick().

That was my thought as well. Since you already made a GUI: How did you listen for the mouse? Did you add an own class for this or where did you put it?

Posted 18 December 2012 - 01:14 AM

Try replacing

myButton.Click += new Action(myButton_Click);
with
myButton.Click += myButton_Click;
or
myButton.Click += () => {Console.Write("foo");};

From what I can tell in the MSDN article, the constructor format of Action doesn't do what you're thinking it does. I'll gladly take some correction on that if I didn't search deep enough though.

Sorry, this doesn't work. It doesn't even compile due to syntax errors.

I would track the mouse position and whether or not it's been clicked in the Window class, and then if the position of the cursor is inside of myButton when a click is dispatched call myButton.OnClick().

That was my thought as well. Since you already made a GUI: How did you listen for the mouse? Did you add an own class for this or where did you put it?

Posted 18 December 2012 - 01:13 AM

Try replacing

myButton.Click += new Action(myButton_Click);
with
myButton.Click += myButton_Click;
or
myButton.Click += () => {Console.Write("foo");};

From what I can tell in the MSDN article, the constructor format of Action doesn't do what you're thinking it does. I'll gladly take some correction on that if I didn't search deep enough though.

Sorry, this doesn't work. It doesn't even compile due to syntax errors.

I would track the mouse position and whether or not it's been clicked in the Window class, and then if the position of the cursor is inside of myButton when a click is dispatched call myButton.OnClick().

That was my thought as well. Since you already made a GUI: How did you listen for the mouse? Did you add an own class for this or where did you put it?

PARTNERS