diff --git a/pygame_menu/widgets/widget/textinput.py b/pygame_menu/widgets/widget/textinput.py index 5211e2d0..3bdabc54 100644 --- a/pygame_menu/widgets/widget/textinput.py +++ b/pygame_menu/widgets/widget/textinput.py @@ -1295,6 +1295,7 @@ def _copy(self) -> bool: except PyperclipException as e: if self._verbose: clipboard_warn(e, 'Copying') + return False self._block_copy_paste = True return True diff --git a/test/test_widget_textinput.py b/test/test_widget_textinput.py index 27574724..c4704dac 100644 --- a/test/test_widget_textinput.py +++ b/test/test_widget_textinput.py @@ -403,8 +403,8 @@ def test_copy_paste(self) -> None: textinput_copy.set_value('this value should be cropped as this is longer than the max char') self.assertFalse(textinput_copy._block_copy_paste) textinput_copy._copy() - self.assertTrue(textinput_copy._block_copy_paste) - textinput_copy._block_copy_paste = False + if textinput_copy._block_copy_paste: # Otherwise, an exception happened + textinput_copy._block_copy_paste = False textinput_copy._select_all() textinput_copy._cut() self.assertEqual(textinput_copy.get_value(), '')