소스 검색

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 ();
 	}
-}
+}