From 8d71d304b9141de4f46098d77d2853da510b432a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 22 Mar 2023 17:24:30 +0100 Subject: [PATCH] Use accelerators for main menu items in the printing sample Allow using Ctrl-P to bring up the "Print" dialog instead of having to select it from the menu every time. And also add an accelerator for the "Page Setup" menu command. And specify both the new accelerators and the existing one for "Print preview" command using the menu items labels instead of calling SetAcceleratorTable() explicitly, as there doesn't seem to be any reason to do it. Finally, slightly improve the help messages for these menu items. --- samples/printing/printing.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index 0d3eb2d4e8..1b2d40623b 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -291,25 +291,18 @@ MyFrame::MyFrame(const wxString& title) // Make a menubar wxMenu *file_menu = new wxMenu; - file_menu->Append(wxID_PRINT, "&Print...", "Print"); - file_menu->Append(WXPRINT_PAGE_SETUP, "Page Set&up...", "Page setup"); + file_menu->Append(wxID_PRINT, "&Print...\tCtrl+P", "Show \"Print\" dialog"); + file_menu->Append(WXPRINT_PAGE_SETUP, "Page &Setup...\tCtrl+S", "Page setup"); #ifdef __WXMAC__ file_menu->Append(WXPRINT_PAGE_MARGINS, "Page Margins...", "Page margins"); #endif - file_menu->Append(wxID_PREVIEW, "Print Pre&view", "Preview"); + file_menu->Append(wxID_PREVIEW, "Pre&view\tCtrl+V", "Show print preview"); wxMenu * const menuModalKind = new wxMenu; menuModalKind->AppendRadioItem(WXPRINT_FRAME_MODAL_APP, "&App modal"); menuModalKind->AppendRadioItem(WXPRINT_FRAME_MODAL_WIN, "&Window modal"); menuModalKind->AppendRadioItem(WXPRINT_FRAME_MODAL_NON, "&Not modal"); file_menu->AppendSubMenu(menuModalKind, "Preview frame &modal kind"); -#if wxUSE_ACCEL - // Accelerators - wxAcceleratorEntry entries[1]; - entries[0].Set(wxACCEL_CTRL, (int) 'V', wxID_PREVIEW); - wxAcceleratorTable accel(1, entries); - SetAcceleratorTable(accel); -#endif #if wxUSE_POSTSCRIPT file_menu->AppendSeparator();