public void Focus() { using (var win = new Window()) { var w = CreateWidget(); HBox box = new HBox(); TextEntry e = new TextEntry(); box.PackStart(e); box.PackStart(w); win.Content = box; win.Show(); win.Present(); Application.MainLoop.DispatchPendingEvents(); e.SetFocus(); Application.MainLoop.DispatchPendingEvents(); Assert.IsFalse(w.HasFocus); // Assert.IsTrue (w.CanGetFocus); int gotFocus = 0; w.GotFocus += delegate { gotFocus++; }; w.SetFocus(); if (w.CanGetFocus) { Assert.IsTrue(w.HasFocus); Assert.AreEqual(1, gotFocus); int lostFocus = 0; w.LostFocus += delegate { lostFocus++; }; e.SetFocus(); Assert.IsFalse(w.HasFocus); // Assert.AreEqual (1, lostFocus); } else { Assert.IsFalse(w.HasFocus); Assert.AreEqual(0, gotFocus); } } }
public void Focus() { using (var win = new Window ()) { var w = CreateWidget (); HBox box = new HBox (); TextEntry e = new TextEntry (); box.PackStart (e); box.PackStart (w); win.Content = box; win.Show (); win.Present (); Application.MainLoop.DispatchPendingEvents (); e.SetFocus (); Application.MainLoop.DispatchPendingEvents (); Assert.IsFalse (w.HasFocus); // Assert.IsTrue (w.CanGetFocus); int gotFocus = 0; w.GotFocus += delegate { gotFocus++; }; w.SetFocus (); if (w.CanGetFocus) { Assert.IsTrue (w.HasFocus); Assert.AreEqual (1, gotFocus); int lostFocus = 0; w.LostFocus += delegate { lostFocus++; }; e.SetFocus (); Assert.IsFalse (w.HasFocus); // Assert.AreEqual (1, lostFocus); } else { Assert.IsFalse (w.HasFocus); Assert.AreEqual (0, gotFocus); } } }
public void Focus() { var win = new Window(); var w = CreateWidget(); Run(delegate { HBox box = new HBox(); TextEntry e = new TextEntry(); box.PackStart(e); box.PackStart(w); win.Content = box; win.Show(); win.Present(); // for (int n=0; n < 500; n++) { Application.DispatchPendingEvents(); // System.Threading.Thread.Sleep (10); // } e.SetFocus(); Application.DispatchPendingEvents(); Assert.IsFalse(w.HasFocus); // Assert.IsTrue (w.CanGetFocus); int gotFocus = 0; w.GotFocus += delegate { gotFocus++; }; w.SetFocus(); Assert.IsTrue(w.HasFocus); Assert.AreEqual(1, gotFocus); int lostFocus = 0; w.LostFocus += delegate { lostFocus++; }; e.SetFocus(); Assert.IsFalse(w.HasFocus); // Assert.AreEqual (1, lostFocus); win.Dispose(); }); }
public void Focus () { var win = new Window (); var w = CreateWidget (); Run (delegate { HBox box = new HBox (); TextEntry e = new TextEntry (); box.PackStart (e); box.PackStart (w); win.Content = box; win.Show (); win.Present (); // for (int n=0; n < 500; n++) { Application.DispatchPendingEvents (); // System.Threading.Thread.Sleep (10); // } e.SetFocus (); Application.DispatchPendingEvents (); Assert.IsFalse (w.HasFocus); // Assert.IsTrue (w.CanGetFocus); int gotFocus = 0; w.GotFocus += delegate { gotFocus++; }; w.SetFocus (); Assert.IsTrue (w.HasFocus); Assert.AreEqual (1, gotFocus); int lostFocus = 0; w.LostFocus += delegate { lostFocus++; }; e.SetFocus (); Assert.IsFalse (w.HasFocus); // Assert.AreEqual (1, lostFocus); win.Dispose (); }); }