Add delete-key shortcut to remove content.
authorCarl Hetherington <cth@carlh.net>
Tue, 2 Feb 2016 00:04:35 +0000 (00:04 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 2 Feb 2016 00:04:35 +0000 (00:04 +0000)
ChangeLog
src/tools/dcpomatic.cc
src/wx/content_panel.cc
src/wx/content_panel.h

index 558990cbc6fcee9858cd0982b0917d7352d7ee0f..1f491a732ceecaf5fd47b7820bbd4a91807acafa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-02-02  Carl Hetherington  <cth@carlh.net>
+
+       * Add Delete-key shortcut to remove content.
+
 2016-02-01  Carl Hetherington  <cth@carlh.net>
 
        * Allow removal of multiple pieces of content in one click.
index 0260cd9a88c3baad1c98e8f77ac77330394b10f0..b853851d7c7328572d472fd707f6114a4b5cef03 100644 (file)
@@ -153,7 +153,8 @@ enum {
        ID_tools_restore_default_preferences,
        ID_help_report_a_problem,
        /* IDs for shortcuts (with no associated menu item) */
-       ID_add_file
+       ID_add_file,
+       ID_remove
 };
 
 class DOMFrame : public wxFrame
@@ -248,10 +249,12 @@ public:
 
                overall_panel->SetSizer (main_sizer);
 
-               wxAcceleratorEntry accel[1];
+               wxAcceleratorEntry accel[2];
                accel[0].Set (wxACCEL_CTRL, static_cast<int>('A'), ID_add_file);
+               accel[1].Set (wxACCEL_NORMAL, WXK_DELETE, ID_remove);
                Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file);
-               wxAcceleratorTable accel_table (1, accel);
+               Bind (wxEVT_MENU, boost::bind (&ContentPanel::remove_clicked, _film_editor->content_panel()), ID_remove);
+               wxAcceleratorTable accel_table (2, accel);
                SetAcceleratorTable (accel_table);
 
                /* Instantly save any config changes when using the DCP-o-matic GUI */
index deeef7f80be5359bb43d640f7b7b7beea62afb30..d1315ac34a08265f543b49feff1c42ac970a4eb4 100644 (file)
@@ -328,6 +328,13 @@ ContentPanel::add_folder_clicked ()
 void
 ContentPanel::remove_clicked ()
 {
+       /* This method is also called when Delete is pressed, so check that our notebook page
+          is visible.
+       */
+       if (_parent->GetCurrentPage() != _panel) {
+               return;
+       }
+
        BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
                _film->remove_content (i);
        }
index 8d11e6289f57f2bc912247c3b7be245c584719bc..1115aaf31c1f8cb44656e56957bcc9e6be118a67 100644 (file)
@@ -65,11 +65,11 @@ public:
        FFmpegContentList selected_ffmpeg ();
 
        void add_file_clicked ();
+       void remove_clicked ();
 
 private:
        void selection_changed ();
        void add_folder_clicked ();
-       void remove_clicked ();
        void earlier_clicked ();
        void later_clicked ();
        void right_click (wxListEvent &);