Jelajahi Sumber

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 tahun lalu
induk
melakukan
3e46047971
1 mengubah file dengan 14 tambahan dan 10 penghapusan
  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 ();
 	}
-}
+}