Skip to content

Commit

Permalink
Enhancement #4436: Made Ctrl-C Shortcut to PDF Text Copy Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorShelton authored and rolandlo committed Apr 11, 2023
1 parent b811fe9 commit 724540d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/core/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ auto MainWindow::onKeyPressCallback(GtkWidget* widget, GdkEventKey* event, MainW
// editing text - give that control
return false;
}
if (event->keyval == GDK_KEY_c && event->state & GDK_CONTROL_MASK) {
// Shortcut to get selected PDF text.
PdfFloatingToolbox* tool = win->getPdfToolbox();
if (tool->hasSelection()) {
tool->copyTextToClipboard();
return true;
}
}
if (event->keyval == GDK_KEY_Escape) {
win->getControl()->getSearchBar()->showSearchBar(false);
return true;
Expand Down
4 changes: 3 additions & 1 deletion src/core/gui/PdfFloatingToolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class PdfFloatingToolbox {
/// Track selection style used for unfinalized selections
XojPdfPageSelectionStyle selectionStyle = XojPdfPageSelectionStyle::Linear;

/// Copy Selection to the Clipboard.
void copyTextToClipboard();

private:
void show();

Expand All @@ -74,7 +77,6 @@ class PdfFloatingToolbox {
static void copyTextCb(GtkButton* button, PdfFloatingToolbox* pft);
static void highlightCb(GtkButton* button, PdfFloatingToolbox* pft);

void copyTextToClipboard();
void createStrokes(PdfMarkerStyle position, PdfMarkerStyle width, int markerOpacity);

private:
Expand Down

0 comments on commit 724540d

Please sign in to comment.