@@ -3693,33 +3693,45 @@ void cmdRemoveOrCopyAreaOfItems(Command* command) {
3693
3693
}
3694
3694
return count;
3695
3695
};
3696
+ ostringstream s;
3696
3697
if (start == end) {
3697
- outputMessage ( translate (" no time selection" ) );
3698
+ s << translate (" no time selection" );
3698
3699
} else {
3699
3700
switch (command->gaccel .accel .cmd ) {
3700
- case 40060 : // Item: Copy selected area of items
3701
- case 40014 : { // Item: Copy loop of selected area of audio items
3701
+ case 40060 :{ // Item: Copy selected area of items
3702
3702
if (selItems == 0 ) {
3703
- outputMessage ( translate (" no items selected" ) );
3703
+ s << translate (" no items selected" );
3704
3704
break ;
3705
3705
}
3706
3706
int count = countAffected (GetSelectedMediaItem, selItems);
3707
3707
// Translators: used for "Item: Copy selected area of items".
3708
3708
// {} is replaced by the number of items affected.
3709
- outputMessage (format (
3710
- translate_plural (" selected area of {} item copied" , " selected area of {} items copied" , count), count));
3709
+ s << format (
3710
+ translate_plural (" selected area of {} item copied" , " selected area of {} items copied" , count), count);
3711
+ break ;
3712
+ }
3713
+ case 40014 : { // Item: Copy loop of selected area of audio items
3714
+ if (selItems == 0 ) {
3715
+ s << translate (" no items selected" );
3716
+ break ;
3717
+ }
3718
+ int count = countAffected (GetSelectedMediaItem, selItems);
3719
+ // Translators: used for "Item: Copy loop of selected area of audio items".
3720
+ // {} is replaced by the number of items affected.
3721
+ s << format (
3722
+ translate_plural (" loop of selected area of {} item copied" , " loop of selected area of {} items copied" , count), count);
3711
3723
break ;
3712
3724
}
3713
3725
case 41296 : { // Item: Duplicate selected area of items
3714
3726
if (selItems == 0 ) {
3715
- outputMessage ( translate (" no items selected" ) );
3727
+ s << translate (" no items selected" );
3716
3728
break ;
3717
3729
}
3718
3730
int count = countAffected (GetSelectedMediaItem, selItems);
3719
3731
// Translators: used for "Item: Duplicate selected area of items".
3720
3732
// {} is replaced by the number of items affected.
3721
- outputMessage ( format (
3722
- translate_plural (" selected area of {} item duplicated" , " selected area of {} items duplicated" , count), count)) ;
3733
+ s << format (
3734
+ translate_plural (" selected area of {} item duplicated" , " selected area of {} items duplicated" , count), count);
3723
3735
break ;
3724
3736
}
3725
3737
default : {
@@ -3729,18 +3741,28 @@ void cmdRemoveOrCopyAreaOfItems(Command* command) {
3729
3741
} else {
3730
3742
count = countAffected (GetSelectedMediaItem, selItems);
3731
3743
}
3732
- ostringstream s;
3733
3744
// Translators: used for "Item: Cut selected area of items" and "Item:
3734
3745
// Remove selected area of items". {} is replaced by the number of items
3735
3746
// affected.
3736
3747
s << format (
3737
3748
translate_plural (" selected area of {} item removed" , " selected area of {} items removed" , count), count);
3738
3749
maybeAddRippleMessage (s, command->gaccel .accel .cmd );
3739
- outputMessage (s);
3740
3750
}
3741
3751
}
3742
3752
}
3753
+ // the command might show an error, so we need to avoid speaking if the focus changes
3754
+ HWND oldFocus = GetFocus ();
3755
+ bool focusChanged = false ;
3756
+ auto later = CallLater ([&focusChanged, &oldFocus] {
3757
+ if (GetFocus () != oldFocus) {
3758
+ focusChanged = true ;
3759
+ }
3760
+ }, 100 );
3743
3761
Main_OnCommand (command->gaccel .accel .cmd , 0 );
3762
+ if (!focusChanged) {
3763
+ outputMessage (s);
3764
+ }
3765
+ later.cancel ();
3744
3766
}
3745
3767
3746
3768
void cmdhRemoveItems (int command) {
0 commit comments