Fix sensitivity of OK in the screen dialog.
authorCarl Hetherington <cth@carlh.net>
Tue, 22 Dec 2015 21:20:01 +0000 (21:20 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 22 Dec 2015 21:20:01 +0000 (21:20 +0000)
src/wx/screen_dialog.cc

index bec5318799e43cf16f6b52fae6265df7315945c3..6c95c0baee7a98f62de7e432744293c89b134864 100644 (file)
@@ -119,11 +119,10 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optiona
        _sizer->Add (_trusted_device_list, wxGBPosition (r, 0), wxGBSpan (1, 3), wxEXPAND);
        ++r;
 
+       _name->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ScreenDialog::setup_sensitivity, this));
        _get_recipient_from_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreenDialog::get_recipient_from_file, this));
        _download_recipient->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreenDialog::download_recipient, this));
 
-       setup_sensitivity ();
-
        overall_sizer->Add (_sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
@@ -133,6 +132,8 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optiona
 
        overall_sizer->Layout ();
        overall_sizer->SetSizeHints (this);
+
+       setup_sensitivity ();
 }
 
 string
@@ -185,7 +186,7 @@ ScreenDialog::setup_sensitivity ()
 {
        wxButton* ok = dynamic_cast<wxButton*> (FindWindowById (wxID_OK, this));
        if (ok) {
-               ok->Enable (static_cast<bool>(_recipient));
+               ok->Enable (static_cast<bool>(_recipient) && !_name->GetValue().IsEmpty());
        }
 }