public DateComboBox() { MinDate = DateTime.MinValue; MaxDate = DateTime.MaxValue; ErrorColor = Colors.Red; NormalColor = Entry.GetTextColor(); Entry.Changed += HandleChanged; Entry.FocusOutEvent += Entry_FocusOutEvent; // called on button press.. PopupButtonClicked += delegate { // if we are still up somehow, take the old dialog down.. if (dlg != null) { // this will appear to the user as a click that doesn't // bring up a window.. dlg.CloseDialog(); CleanDialog(); } else { #if GTKCORE // move the focus to the Entry control so we can detect it moving away.. Entry.GrabFocusWithoutSelecting(); #endif dlg = new DateComboBoxDialog(selectedDate ?? DateTime.Now, this.Mode); dlg.DateChanged += Dlg_DateChanged; dlg.DialogClosed += Dlg_DialogClosed; dlg.ShowPopup(this); } }; }
/// <summary> /// If the drop down dialog is up and lose focus on the parent field, close it /// </summary> /// <param name="o"></param> /// <param name="args"></param> private void Entry_FocusOutEvent(object o, Gtk.FocusOutEventArgs args) { // if the pull-down is are up, close it dlg?.CloseDialog(); }