Преглед изворни кода

Fix NewFile modal

Old code is not valid. 1) You can't add event handler in object initializer. 2) ml2 isn't used outside of the method. So you can use local variable.
Pavel Kurkutov пре 4 година
родитељ
комит
3e46047971
1 измењених фајлова са 14 додато и 10 уклоњено
  1. 14 10
      StandaloneExample/Program.cs

+ 14 - 10
StandaloneExample/Program.cs

@@ -141,17 +141,21 @@ class Demo {
 
 	}
 
-	public static Label ml2;
-
 	static void NewFile ()
 	{
-		var d = new Dialog (
-			"New File", 50, 20,
-			new Button ("Ok", is_default: true) { Clicked = () => { Application.RequestStop (); } },
-			new Button ("Cancel") { Clicked = () => { Application.RequestStop (); } });
-		ml2 = new Label (1, 1, "Mouse Debug Line");
-		d.Add (ml2);
-		Application.Run (d);
+		var okButton = new Button ("Ok", is_default: true);
+                okButton.Clicked += () => { Application.RequestStop (); };
+                var cancelButton = new Button ("Cancel");
+                cancelButton.Clicked += () => { Application.RequestStop (); };
+
+                var d = new Dialog (
+                    "New File", 50, 20,
+                    okButton,
+                    cancelButton);
+
+                var ml2 = new Label (1, 1, "Mouse Debug Line");
+                d.Add (ml2);
+                Application.Run (d);
 	}
 
 	static bool Quit ()
@@ -207,4 +211,4 @@ class Demo {
 		top.Add (menu);
 		Application.Run ();
 	}
-}
+}