mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-18 01:19:45 +08:00
Allow selecting between primary and clipboard in text sample
Add a menu item to switch between using the clipboard and primary
selections.
This finally makes UsePrimarySelection() call in the sample useful,
after 25 years when it didn't do anything, since it was added back in
7e2c43b855 (...Added for primary selection to sample/text., 1999-06-10)
This commit is contained in:
+10
-3
@@ -410,6 +410,7 @@ enum
|
||||
TEXT_CLIPBOARD_COPY = 200,
|
||||
TEXT_CLIPBOARD_PASTE,
|
||||
TEXT_CLIPBOARD_VETO,
|
||||
TEXT_CLIPBOARD_USE_PRIMARY,
|
||||
|
||||
// tooltip menu
|
||||
TEXT_TOOLTIPS_SETDELAY = 300,
|
||||
@@ -491,6 +492,10 @@ bool MyApp::OnInit()
|
||||
menuClipboard->Append(TEXT_CLIPBOARD_PASTE, "&Paste\tCtrl-Shift-V",
|
||||
"Paste from clipboard to the text control");
|
||||
menuClipboard->AppendSeparator();
|
||||
menuClipboard->AppendCheckItem(TEXT_CLIPBOARD_USE_PRIMARY,
|
||||
"Use &primary selection\tCtrl-Shift-P",
|
||||
"If checked, use primary selection instead of clipboard");
|
||||
menuClipboard->AppendSeparator();
|
||||
menuClipboard->AppendCheckItem(TEXT_CLIPBOARD_VETO, "Vet&o\tCtrl-Shift-O",
|
||||
"Veto all clipboard operations");
|
||||
menu_bar->Append(menuClipboard, "&Clipboard");
|
||||
@@ -1315,9 +1320,11 @@ wxTextCtrl *MyPanel::GetFocusedText() const
|
||||
#if wxUSE_CLIPBOARD
|
||||
void MyPanel::SelectClipboardSelection()
|
||||
{
|
||||
// On X11, we want to exchange data with the clipboard selection instead
|
||||
// of the primary selection -- which is actually the case by default.
|
||||
wxTheClipboard->UsePrimarySelection(false);
|
||||
wxFrame *frame = wxDynamicCast(wxGetTopLevelParent(this), wxFrame);
|
||||
wxCHECK_RET( frame, "no parent frame?" );
|
||||
|
||||
wxTheClipboard->UsePrimarySelection(
|
||||
frame->GetMenuBar()->IsChecked(TEXT_CLIPBOARD_USE_PRIMARY));
|
||||
}
|
||||
|
||||
void MyPanel::DoPasteFromClipboard()
|
||||
|
||||
Reference in New Issue
Block a user