Skip to content

Commit

Permalink
Copy/paste into correct text field (fixes #766).
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp committed Jul 22, 2024
1 parent c3e73d2 commit 376ad8a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions rednotebook/gui/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,23 +363,28 @@ def on_redo(self, widget):
editor = self.main_window.day_text_field
editor.day_text_buffer.redo()

def _forward_signal_to_focused_widget(self, signal_name):
widget = self.main_window.main_frame.get_focus()
try:
widget.emit(signal_name)
except AttributeError:
# No widget in focus.
pass
except TypeError:
# Focus is on a widget that doesn't support this signal.
pass

def on_copy_menu_item_activate(self, widget):
if self.main_window.preview_mode:
self.main_window.html_editor.copy_to_clipboard()
else:
self.main_window.day_text_field.day_text_view.emit("copy_clipboard")
self._forward_signal_to_focused_widget("copy_clipboard")

def on_paste_menu_item_activate(self, widget):
if self.main_window.preview_mode:
pass
else:
self.main_window.day_text_field.day_text_view.emit("paste_clipboard")
self._forward_signal_to_focused_widget("paste_clipboard")

def on_cut_menu_item_activate(self, widget):
if self.main_window.preview_mode:
pass
else:
self.main_window.day_text_field.day_text_view.emit("cut_clipboard")
self._forward_signal_to_focused_widget("cut_clipboard")

def on_fullscreen_menuitem_activate(self, widget):
self.main_window.toggle_fullscreen()
Expand Down

0 comments on commit 376ad8a

Please sign in to comment.