KiCad PCB EDA Suite
ee_hotkeys.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <fctsys.h>
27 #include <id.h>
28 #include <eeschema_id.h>
29 #include <ee_hotkeys.h>
30 #include <sch_edit_frame.h>
31 #include <sch_draw_panel.h>
32 
33 #include <general.h>
34 #include <lib_edit_frame.h>
35 #include <viewlib_frame.h>
36 #include <class_libentry.h>
37 #include <sch_junction.h>
38 #include <sch_line.h>
39 #include <sch_component.h>
40 #include <sch_sheet.h>
41 
43 #include <tool/tool_manager.h>
45 #include <tools/ee_actions.h>
46 
47 // Remark: the hotkey message info is used as keyword in hotkey config files and
48 // as comments in help windows, therefore translated only when displayed
49 // they are marked _HKI to be extracted by translation tools
50 // See hotkeys_basic.h for more info
51 
52 
53 /* How to add a new hotkey:
54  * add a new id in the enum hotkey_id_command like MY_NEW_ID_FUNCTION (see
55  * hotkeys.h).
56  * add a new EDA_HOTKEY entry like:
57  * static EDA_HOTKEY HkMyNewEntry(_HKI("Command Label"), MY_NEW_ID_FUNCTION,
58  * default key value);
59  * _HKI("Command Label") is the name used in hotkey list display, and the
60  * identifier in the hotkey list file
61  * MY_NEW_ID_FUNCTION is an equivalent id function used in the switch in
62  * OnHotKey() function.
63  * default key value is the default hotkey for this command. Can be overridden
64  * by the user hotkey list file
65  * add the HkMyNewEntry pointer in the schematic_Hotkey_List list or the
66  * libEdit_Hotkey_List list or common_Hotkey_List if the same command is
67  * added both in Eeschema and libedit)
68  * Add the new code in the switch in OnHotKey() function.
69  * when the variable itemInEdit is true, an item is currently edited.
70  * This can be useful if the new function cannot be executed while an item is
71  * currently being edited
72  * ( For example, one cannot start a new wire when a component is moving.)
73  *
74  * Note: If an hotkey is a special key be sure the corresponding wxWidget
75  * keycode (WXK_XXXX) is handled in the hotkey_name_descr
76  * s_Hotkey_Name_List list (see hotkeys_basic.cpp) and see this list
77  * for some ascii keys (space ...)
78  *
79  * Key modifier are: GR_KB_CTRL GR_KB_ALT
80  */
81 
82 
83 // Common commands
84 
85 // Fit on Screen
86 #if !defined( __WXMAC__ )
87 static EDA_HOTKEY HkZoomAuto( _HKI( "Fit on Screen" ), HK_ZOOM_AUTO, WXK_HOME,
88  ID_ZOOM_PAGE );
89 #else
90 static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0',
91  ID_ZOOM_PAGE );
92 #endif
93 
94 static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4,
96 
97 // Refresh Screen
98 #if !defined( __WXMAC__ )
99 static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3,
100  ID_ZOOM_REDRAW );
101 #else
102 static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTRL + 'R',
103  ID_ZOOM_REDRAW );
104 #endif
105 
106 // Zoom In
107 #if !defined( __WXMAC__ )
108 static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1,
109  ID_KEY_ZOOM_IN );
110 #else
111 static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+',
112  ID_KEY_ZOOM_IN );
113 #endif
114 
115 // Zoom Out
116 #if !defined( __WXMAC__ )
117 static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2,
118  ID_KEY_ZOOM_OUT );
119 #else
120 static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-',
121  ID_KEY_ZOOM_OUT );
122 #endif
123 
124 static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' + GR_KB_CTRL );
125 
126 static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
127 static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ), HK_PREFERENCES, GR_KB_CTRL + ',',
128  wxID_PREFERENCES );
129 static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
130 static EDA_HOTKEY HkLeaveSheet( _HKI( "Leave Sheet" ), HK_LEAVE_SHEET, GR_KB_ALT + WXK_BACK,
132 
133 // mouse click command:
134 static EDA_HOTKEY HkMouseLeftClick( _HKI( "Mouse Left Click" ), HK_LEFT_CLICK, WXK_RETURN,
135  ID_MOUSE_CLICK );
136 static EDA_HOTKEY HkMouseLeftDClick( _HKI( "Mouse Left Double Click" ), HK_LEFT_DCLICK, WXK_END,
138 
139 // Schematic editor
140 static EDA_HOTKEY HkBeginWire( _HKI( "Begin Wire" ), HK_BEGIN_WIRE, 'W',
141  ID_WIRE_TOOL );
142 static EDA_HOTKEY HkBeginBus( _HKI( "Begin Bus" ), HK_BEGIN_BUS, 'B',
143  ID_BUS_TOOL );
144 static EDA_HOTKEY HkEndLineWireBus( _HKI( "End Line Wire Bus" ), HK_END_CURR_LINEWIREBUS, 'K' );
145 
146 static EDA_HOTKEY HkAddLabel( _HKI( "Add Label" ), HK_ADD_LABEL, 'L',
147  ID_LABEL_TOOL );
148 static EDA_HOTKEY HkAddHierarchicalLabel( _HKI( "Add Hierarchical Label" ), HK_ADD_HLABEL, 'H',
150 static EDA_HOTKEY HkAddGlobalLabel( _HKI( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'H',
152 static EDA_HOTKEY HkAddJunction( _HKI( "Add Junction" ), HK_ADD_JUNCTION, 'J',
154 static EDA_HOTKEY HkAddComponent( _HKI( "Add Symbol" ), HK_ADD_NEW_COMPONENT, 'A',
156 static EDA_HOTKEY HkAddPower( _HKI( "Add Power" ), HK_ADD_NEW_POWER, 'P',
158 static EDA_HOTKEY HkAddNoConn( _HKI( "Add No Connect Flag" ), HK_ADD_NOCONN_FLAG, 'Q',
160 static EDA_HOTKEY HkAddHierSheet( _HKI( "Add Sheet" ), HK_ADD_HIER_SHEET, 'S',
161  ID_SHEET_TOOL );
162 static EDA_HOTKEY HkAddBusEntry( _HKI( "Add Bus Entry" ), HK_ADD_BUS_ENTRY, '/',
164 static EDA_HOTKEY HkAddWireEntry( _HKI( "Add Wire Entry" ), HK_ADD_WIRE_ENTRY, 'Z',
166 static EDA_HOTKEY HkAddGraphicPolyLine( _HKI( "Add Graphic PolyLine" ), HK_ADD_GRAPHIC_POLYLINE, 'I',
168 static EDA_HOTKEY HkAddGraphicText( _HKI( "Add Graphic Text" ), HK_ADD_GRAPHIC_TEXT, 'T',
170 static EDA_HOTKEY HkMirrorY( _HKI( "Mirror Y" ), HK_MIRROR_Y, 'Y' );
171 static EDA_HOTKEY HkMirrorX( _HKI( "Mirror X" ), HK_MIRROR_X, 'X' );
172 static EDA_HOTKEY HkRotate( _HKI( "Rotate Item" ), HK_ROTATE, 'R' );
173 static EDA_HOTKEY HkEdit( _HKI( "Edit Item" ), HK_EDIT, 'E' );
174 static EDA_HOTKEY HkEditValue( _HKI( "Edit Symbol Value" ), HK_EDIT_COMPONENT_VALUE, 'V' );
175 static EDA_HOTKEY HkEditReference( _HKI( "Edit Symbol Reference" ), HK_EDIT_COMPONENT_REFERENCE, 'U' );
176 static EDA_HOTKEY HkEditFootprint( _HKI( "Edit Symbol Footprint" ), HK_EDIT_COMPONENT_FOOTPRINT, 'F' );
177 static EDA_HOTKEY HkShowDatasheet( _HKI( "Show Symbol Datasheet" ), HK_SHOW_COMPONENT_DATASHEET, 'D',
179 static EDA_HOTKEY HkEditWithLibedit( _HKI( "Edit with Symbol Editor" ), HK_EDIT_COMPONENT_WITH_LIBEDIT, 'E' + GR_KB_CTRL,
181 
182 static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE, 'M' );
183 
184 static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate" ), HK_DUPLICATE, 'D' + GR_KB_CTRL );
185 
186 static EDA_HOTKEY HkDrag( _HKI( "Drag Item" ), HK_DRAG, 'G' );
187 static EDA_HOTKEY HkInsert( _HKI( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
188 static EDA_HOTKEY HkDelete( _HKI( "Delete Item" ), HK_DELETE, WXK_DELETE );
189 
190 static EDA_HOTKEY HkFindItem( _HKI( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL,
191  ID_FIND_ITEMS );
192 static EDA_HOTKEY HkFindNextItem( _HKI( "Find Next Item" ), HK_FIND_NEXT_ITEM, WXK_F5,
193  wxEVT_COMMAND_FIND );
194 static EDA_HOTKEY HkFindReplace( _HKI( "Find and Replace" ), HK_FIND_REPLACE, 'F' + GR_KB_CTRL + GR_KB_ALT,
195  wxID_REPLACE );
196 static EDA_HOTKEY HkFindNextMarker( _HKI( "Find Next Marker" ), HK_FIND_NEXT_DRC_MARKER, WXK_F5 + GR_KB_SHIFT,
197  EVT_COMMAND_FIND_DRC_MARKER );
198 static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION, GR_KB_CTRL + WXK_F5,
200 
201 // Special keys for library editor:
202 static EDA_HOTKEY HkCreatePin( _HKI( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P',
204 static EDA_HOTKEY HkInsertPin( _HKI( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
205 static EDA_HOTKEY HkViewDoc( _HKI( "Show Datasheet" ), HK_LIBEDIT_VIEW_DOC, 'D' + GR_KB_ALT,
207 
208 // Autoplace fields
209 static EDA_HOTKEY HkAutoplaceFields( _HKI( "Autoplace Fields" ), HK_AUTOPLACE_FIELDS, 'O' );
210 
211 static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UPDATE_PCB_FROM_SCH, WXK_F8,
213 
214 // Selection
215 static EDA_HOTKEY HkSelectNode( _HKI( "Select Node" ), HK_SELECT_NODE, GR_KB_ALT + '3',
217 static EDA_HOTKEY HkSelectConnection( _HKI( "Select Connection" ), HK_SELECT_CONNECTION, GR_KB_ALT + '4',
219 
220 // Higtlight connection
221 static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Net" ), ID_HOTKEY_HIGHLIGHT, 'B' + GR_KB_CTRL,
223 
224 static EDA_HOTKEY HkUnfoldBus( _HKI( "Unfold from Bus" ), HK_UNFOLD_BUS, 'C',
226 
227 // Common: hotkeys_basic.h
228 static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N',
229  wxID_NEW );
230 static EDA_HOTKEY HkOpen( _HKI( "Open" ), HK_OPEN, GR_KB_CTRL + 'O',
231  wxID_OPEN );
232 static EDA_HOTKEY HkSave( _HKI( "Save" ), HK_SAVE, GR_KB_CTRL + 'S',
233  wxID_SAVE );
234 static EDA_HOTKEY HkSaveAs( _HKI( "Save As" ), HK_SAVEAS, GR_KB_SHIFT + GR_KB_CTRL + 'S',
235  wxID_SAVEAS );
236 static EDA_HOTKEY HkPrint( _HKI( "Print" ), HK_PRINT, GR_KB_CTRL + 'P',
237  wxID_PRINT );
238 
239 static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z',
240  wxID_UNDO );
241 
242 #if !defined( __WXMAC__ )
243 static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y',
244  wxID_REDO );
245 #else
246 static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_SHIFTCTRL + 'Z',
247  wxID_REDO );
248 #endif
249 
250 static EDA_HOTKEY HkEditCut( _HKI( "Cut" ), HK_EDIT_CUT, GR_KB_CTRL + 'X',
251  wxID_CUT );
252 static EDA_HOTKEY HkEditCopy( _HKI( "Copy" ), HK_EDIT_COPY, GR_KB_CTRL + 'C',
253  wxID_COPY );
254 static EDA_HOTKEY HkEditPaste( _HKI( "Paste" ), HK_EDIT_PASTE, GR_KB_CTRL + 'V',
255  wxID_PASTE );
256 
257 static EDA_HOTKEY HkCanvasOpenGL( _HKI( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ),
259 #ifdef __WXMAC__
260  GR_KB_ALT +
261 #endif
262  WXK_F11, ID_MENU_CANVAS_OPENGL );
263 static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Modern Toolset with software graphics (fall-back)" ),
265 #ifdef __WXMAC__
266  GR_KB_ALT +
267 #endif
268  WXK_F12, ID_MENU_CANVAS_CAIRO );
269 
270 // List of common hotkey descriptors
272 {
274  &HkUndo, &HkRedo,
276  &HkHelp,
277  &HkPreferences,
278  &HkZoomIn,
279  &HkZoomOut,
280  &HkZoomRedraw,
281  &HkZoomCenter,
282  &HkZoomAuto,
284  &HkSwitchUnits,
286  &HkEdit,
288  &HkDelete,
289  &HkRotate,
290  &HkDrag,
291  &HkMove,
292  &HkMirrorX,
293  &HkMirrorY,
296  NULL
297 };
298 
299 // List of common hotkey descriptors, for the library viewer
301 {
302  &HkHelp,
303  &HkZoomIn,
304  &HkZoomOut,
305  &HkZoomRedraw,
306  &HkZoomCenter,
307  &HkZoomAuto,
309  &HkEdit,
311  &HkDelete,
312  &HkRotate,
313  &HkMove,
314  &HkMirrorX,
315  &HkMirrorY,
318  NULL
319 };
320 
321 // List of hotkey descriptors for schematic
323 {
324  &HkFindItem,
327  &HkFindReplace,
328  &HkInsert,
330  &HkAddPower,
331  &HkEditValue,
336  &HkSelectNode,
338  &HkBeginWire,
339  &HkBeginBus,
341  &HkAddLabel,
344  &HkAddJunction,
345  &HkAddNoConn,
348  &HkAddBusEntry,
353  &HkLeaveSheet,
355  &HkUnfoldBus,
356  &HkCanvasCairo,
358  NULL
359 };
360 
361 // List of hotkey descriptors for library editor
363 {
364  &HkCreatePin,
365  &HkInsertPin,
366  &HkViewDoc,
367  NULL
368 };
369 
370 // List of hotkey descriptors for library viewer (currently empty
372 {
373  NULL
374 };
375 
376 // Keyword Identifiers (tags) in key code configuration file (section names)
377 // (.m_SectionTag member of a EDA_HOTKEY_CONFIG)
378 static wxString schematicSectionTag( wxT( "[eeschema]" ) );
379 static wxString libEditSectionTag( wxT( "[libedit]" ) );
380 
381 // Titles for hotkey editor and hotkey display
382 static wxString commonSectionTitle( _HKI( "Common" ) );
383 static wxString schematicSectionTitle( _HKI( "Schematic Editor" ) );
384 static wxString libEditSectionTitle( _HKI( "Library Editor" ) );
385 
386 // list of sections and corresponding hotkey list for Eeschema (used to create
387 // an hotkey config file)
389 {
393  { NULL, NULL, NULL }
394 };
395 
396 // list of sections and corresponding hotkey list for the schematic editor
397 // (used to list current hotkeys)
399 {
402  { NULL, NULL, NULL }
403 };
404 
405 // list of sections and corresponding hotkey list for the component editor
406 // (used to list current hotkeys)
408 {
411  { NULL, NULL, NULL }
412 };
413 
414 // list of sections and corresponding hotkey list for the component browser
415 // (used to list current hotkeys)
417 {
419  { NULL, NULL, NULL }
420 };
421 
422 
424 {
425  EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List );
426 
427  if( HK_Descr == NULL )
428  HK_Descr = GetDescriptorFromCommand( aCommand, schematic_Hotkey_List );
429 
430  return HK_Descr;
431 }
432 
433 
434 /*
435  * Hot keys. Commands are case insensitive.
436  */
437 bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
438 {
439  if( aHotKey == 0 )
440  return false;
441 
442  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
444  SELECTION& selection = selTool->GetSelection();
445 
446  /* Convert lower to upper case (the usual toupper function has problem
447  * with non ascii codes like function keys */
448  if( (aHotKey >= 'a') && (aHotKey <= 'z') )
449  aHotKey += 'A' - 'a';
450 
451  // Search command from key :
453 
454  if( hotKey == NULL )
455  hotKey = GetDescriptorFromHotkey( aHotKey, schematic_Hotkey_List );
456 
457  if( hotKey == NULL )
458  return false;
459 
460  switch( hotKey->m_Idcommand )
461  {
462  default:
463  case HK_NOT_FOUND:
464  return false;
465 
466  case HK_HELP: // Display Current hotkey list
468  break;
469 
470  case HK_PREFERENCES:
471  cmd.SetId( wxID_PREFERENCES );
472  GetEventHandler()->ProcessEvent( cmd );
473  break;
474 
475  case HK_RESET_LOCAL_COORD: // Reset the relative coord
477  break;
478 
479  case HK_UNDO: // Hot keys that map to command IDs that cannot be called
480  case HK_REDO: // while busy performing another command.
481  case HK_FIND_ITEM:
482  case HK_FIND_REPLACE:
483  if( EE_CONDITIONS::Idle( selection ) )
484  {
485  cmd.SetId( hotKey->m_IdMenuEvent );
486  GetEventHandler()->ProcessEvent( cmd );
487  }
488  break;
489 
490  case HK_FIND_NEXT_ITEM:
492  if( EE_CONDITIONS::Idle( selection ) )
493  {
494  wxFindDialogEvent event( hotKey->m_IdMenuEvent, GetId() );
495  event.SetEventObject( this );
496  event.SetFlags( m_findReplaceData->GetFlags() );
497  event.SetFindString( m_findReplaceData->GetFindString() );
498  GetEventHandler()->ProcessEvent( event );
499  }
500  break;
501 
502  case HK_CANVAS_CAIRO:
503  case HK_CANVAS_OPENGL:
504  {
505  EDA_HOTKEY_CLIENT_DATA data( aPosition );
506  cmd.SetInt( hotKey->m_Idcommand );
507  cmd.SetClientObject( &data );
508  cmd.SetId( hotKey->m_IdMenuEvent );
509  GetEventHandler()->ProcessEvent( cmd );
510  }
511  break;
512  }
513 
514  // Hot key handled.
515  return true;
516 }
517 
518 
520 {
521  EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List );
522 
523  if( HK_Descr == NULL )
524  HK_Descr = GetDescriptorFromCommand( aCommand, libEdit_Hotkey_List );
525 
526  return HK_Descr;
527 }
528 
529 
530 bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
531 {
532  if( aHotKey == 0 )
533  return false;
534 
535  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
537  SELECTION& selection = selTool->GetSelection();
538 
539  cmd.SetEventObject( this );
540 
541  /* Convert lower to upper case (the usual toupper function has problem
542  * with non ascii codes like function keys */
543  if( (aHotKey >= 'a') && (aHotKey <= 'z') )
544  aHotKey += 'A' - 'a';
545 
547 
548  if( hotKey == NULL )
549  hotKey = GetDescriptorFromHotkey( aHotKey, libEdit_Hotkey_List );
550 
551  if( hotKey == NULL )
552  return false;
553 
554  switch( hotKey->m_Idcommand )
555  {
556  default:
557  case HK_NOT_FOUND:
558  return false;
559 
560  case HK_HELP: // Display Current hotkey list
562  break;
563 
564  case HK_PREFERENCES:
565  cmd.SetId( wxID_PREFERENCES );
566  GetEventHandler()->ProcessEvent( cmd );
567  break;
568 
569  case HK_RESET_LOCAL_COORD: // Reset the relative coord
571  break;
572 
573  case HK_EDIT_PASTE:
574  case HK_EDIT_COPY:
575  case HK_EDIT_CUT:
576  cmd.SetId( hotKey->m_IdMenuEvent );
577  GetEventHandler()->ProcessEvent( cmd );
578  break;
579 
580  case HK_UNDO:
581  case HK_REDO:
582  if( EE_CONDITIONS::Idle( selection ) )
583  {
584  cmd.SetId( hotKey->m_IdMenuEvent );
585  GetEventHandler()->ProcessEvent( cmd );
586  }
587  break;
588  }
589 
590  // Hot key handled.
591  return true;
592 }
593 
594 
596 {
597  EDA_HOTKEY* HK_Descr = GetDescriptorFromCommand( aCommand, common_Hotkey_List );
598 
599  if( HK_Descr == NULL )
600  HK_Descr = GetDescriptorFromCommand( aCommand, viewlib_Hotkey_List );
601 
602  return HK_Descr;
603 }
604 
605 
606 bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
607 {
608  if( aHotKey == 0 )
609  return false;
610 
611  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
612  cmd.SetEventObject( this );
613 
614  /* Convert lower to upper case (the usual toupper function has problem with non ascii
615  * codes like function keys */
616  if( (aHotKey >= 'a') && (aHotKey <= 'z') )
617  aHotKey += 'A' - 'a';
618 
620 
621  if( HK_Descr == NULL )
622  HK_Descr = GetDescriptorFromHotkey( aHotKey, viewlib_Hotkey_List );
623 
624  if( HK_Descr == NULL )
625  return false;
626 
627  switch( HK_Descr->m_Idcommand )
628  {
629  default:
630  case HK_NOT_FOUND:
631  return false;
632 
633  case HK_HELP: // Display Current hotkey list
635  break;
636 
637  case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin
639  break;
640 
641  case HK_ZOOM_IN:
642  cmd.SetId( ID_KEY_ZOOM_IN );
643  GetEventHandler()->ProcessEvent( cmd );
644  break;
645 
646  case HK_ZOOM_OUT:
647  cmd.SetId( ID_KEY_ZOOM_OUT );
648  GetEventHandler()->ProcessEvent( cmd );
649  break;
650 
651  case HK_ZOOM_REDRAW:
652  cmd.SetId( ID_ZOOM_REDRAW );
653  GetEventHandler()->ProcessEvent( cmd );
654  break;
655 
656  case HK_ZOOM_CENTER:
657  cmd.SetId( ID_POPUP_ZOOM_CENTER );
658  GetEventHandler()->ProcessEvent( cmd );
659  break;
660 
661  case HK_ZOOM_AUTO:
662  cmd.SetId( ID_ZOOM_PAGE );
663  GetEventHandler()->ProcessEvent( cmd );
664  break;
665 
666  case HK_CANVAS_CAIRO:
667  case HK_CANVAS_OPENGL:
668  cmd.SetInt( HK_Descr->m_Idcommand );
669  cmd.SetId( HK_Descr->m_IdMenuEvent );
670  GetEventHandler()->ProcessEvent( cmd );
671  }
672 
673  return true;
674 }
SELECTION & GetSelection()
Function GetSelection()
#define GR_KB_ALT
static EDA_HOTKEY * common_basic_Hotkey_List[]
Definition: ee_hotkeys.cpp:300
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:94
static EDA_HOTKEY HkUndo(_HKI("Undo"), HK_UNDO, GR_KB_CTRL+ 'Z', wxID_UNDO)
struct EDA_HOTKEY_CONFIG g_Viewlib_Hotkeys_Descr[]
Definition: ee_hotkeys.cpp:416
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Definition: ee_hotkeys.cpp:530
static EDA_HOTKEY HkEditReference(_HKI("Edit Symbol Reference"), HK_EDIT_COMPONENT_REFERENCE, 'U')
static EDA_HOTKEY HkMirrorY(_HKI("Mirror Y"), HK_MIRROR_Y, 'Y')
static EDA_HOTKEY HkPrint(_HKI("Print"), HK_PRINT, GR_KB_CTRL+ 'P', wxID_PRINT)
static EDA_HOTKEY HkEditWithLibedit(_HKI("Edit with Symbol Editor"), HK_EDIT_COMPONENT_WITH_LIBEDIT, 'E'+GR_KB_CTRL, ID_SCH_CALL_LIBEDIT_AND_LOAD_CMP)
static EDA_HOTKEY HkAddJunction(_HKI("Add Junction"), HK_ADD_JUNCTION, 'J', ID_JUNCTION_TOOL)
static EDA_HOTKEY * schematic_Hotkey_List[]
Definition: ee_hotkeys.cpp:322
static EDA_HOTKEY HkAddGraphicPolyLine(_HKI("Add Graphic PolyLine"), HK_ADD_GRAPHIC_POLYLINE, 'I', ID_SCHEMATIC_LINE_TOOL)
static wxString schematicSectionTag(wxT("[eeschema]"))
static EDA_HOTKEY HkAddLabel(_HKI("Add Label"), HK_ADD_LABEL, 'L', ID_LABEL_TOOL)
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
Definition: ee_hotkeys.cpp:595
static wxString libEditSectionTitle(_HKI("Library Editor"))
static EDA_HOTKEY HkFindNextItem(_HKI("Find Next Item"), HK_FIND_NEXT_ITEM, WXK_F5, wxEVT_COMMAND_FIND)
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem) override
Definition: ee_hotkeys.cpp:437
static EDA_HOTKEY HkMouseLeftDClick(_HKI("Mouse Left Double Click"), HK_LEFT_DCLICK, WXK_END, ID_MOUSE_DOUBLECLICK)
static EDA_HOTKEY HkFindReplace(_HKI("Find and Replace"), HK_FIND_REPLACE, 'F'+GR_KB_CTRL+GR_KB_ALT, wxID_REPLACE)
static EDA_HOTKEY HkAddBusEntry(_HKI("Add Bus Entry"), HK_ADD_BUS_ENTRY, '/', ID_BUSTOBUS_ENTRY_TOOL)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static EDA_HOTKEY * viewlib_Hotkey_List[]
Definition: ee_hotkeys.cpp:371
static EDA_HOTKEY HkSelectConnection(_HKI("Select Connection"), HK_SELECT_CONNECTION, GR_KB_ALT+ '4', ID_HOTKEY_SELECT_CONNECTION)
static wxString schematicSectionTitle(_HKI("Schematic Editor"))
#define GR_KB_CTRL
wxFindReplaceData * m_findReplaceData
static EDA_HOTKEY HkAddPower(_HKI("Add Power"), HK_ADD_NEW_POWER, 'P', ID_PLACE_POWER_TOOL)
static EDA_HOTKEY HkDelete(_HKI("Delete Item"), HK_DELETE, WXK_DELETE)
static EDA_HOTKEY * libEdit_Hotkey_List[]
Definition: ee_hotkeys.cpp:362
static EDA_HOTKEY HkOpen(_HKI("Open"), HK_OPEN, GR_KB_CTRL+ 'O', wxID_OPEN)
static SELECTION_CONDITION Idle
static EDA_HOTKEY HkEditValue(_HKI("Edit Symbol Value"), HK_EDIT_COMPONENT_VALUE, 'V')
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
Definition: ee_hotkeys.cpp:519
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
static EDA_HOTKEY HkAddHierSheet(_HKI("Add Sheet"), HK_ADD_HIER_SHEET, 'S', ID_SHEET_TOOL)
static EDA_HOTKEY HkMove(_HKI("Move Schematic Item"), HK_MOVE, 'M')
static EDA_HOTKEY HkBeginBus(_HKI("Begin Bus"), HK_BEGIN_BUS, 'B', ID_BUS_TOOL)
static wxString libEditSectionTag(wxT("[libedit]"))
static EDA_HOTKEY HkRedo(_HKI("Redo"), HK_REDO, GR_KB_CTRL+ 'Y', wxID_REDO)
EDA_HOTKEY * GetDescriptorFromHotkey(int aKey, EDA_HOTKEY **aList)
Function GetDescriptorFromHotkey Return a EDA_HOTKEY * pointer from a key code for OnHotKey() functio...
struct EDA_HOTKEY_CONFIG g_Eeschema_Hotkeys_Descr[]
Definition: ee_hotkeys.cpp:388
static EDA_HOTKEY HkEditFootprint(_HKI("Edit Symbol Footprint"), HK_EDIT_COMPONENT_FOOTPRINT, 'F')
static EDA_HOTKEY HkAddGlobalLabel(_HKI("Add Global Label"), HK_ADD_GLABEL, GR_KB_CTRL+ 'H', ID_GLOBALLABEL_TOOL)
static EDA_HOTKEY HkAddNoConn(_HKI("Add No Connect Flag"), HK_ADD_NOCONN_FLAG, 'Q', ID_NOCONNECT_TOOL)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static EDA_HOTKEY HkSave(_HKI("Save"), HK_SAVE, GR_KB_CTRL+ 'S', wxID_SAVE)
Class EDA_HOTKEY_CLIENT_DATA provides client data member for hotkeys to include in command events gen...
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
static EDA_HOTKEY HkEdit(_HKI("Edit Item"), HK_EDIT, 'E')
static EDA_HOTKEY * common_Hotkey_List[]
Definition: ee_hotkeys.cpp:271
static EDA_HOTKEY HkCanvasCairo(_HKI("Switch to Modern Toolset with software graphics (fall-back)"), HK_CANVAS_CAIRO, WXK_F12, ID_MENU_CANVAS_CAIRO)
static EDA_HOTKEY HkZoomAuto(_HKI("Fit on Screen"), HK_ZOOM_AUTO, WXK_HOME, ID_ZOOM_PAGE)
static EDA_HOTKEY HkZoomOut(_HKI("Zoom Out"), HK_ZOOM_OUT, WXK_F2, ID_KEY_ZOOM_OUT)
static EDA_HOTKEY HkHelp(_HKI("List Hotkeys"), HK_HELP, GR_KB_CTRL+WXK_F1)
static EDA_HOTKEY HkZoomSelection(_HKI("Zoom to Selection"), HK_ZOOM_SELECTION, GR_KB_CTRL+WXK_F5, ID_ZOOM_SELECTION)
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
Class LIB_ITEM definition.
TOOL_MANAGER * GetToolManager() const override
Return the tool manager instance, if any.
Definition: draw_frame.h:937
static EDA_HOTKEY HkMirrorX(_HKI("Mirror X"), HK_MIRROR_X, 'X')
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem) override
Handle hot key events.
Definition: ee_hotkeys.cpp:606
static EDA_HOTKEY HkPreferences(_HKI("Preferences"), HK_PREFERENCES, GR_KB_CTRL+',', wxID_PREFERENCES)
static EDA_HOTKEY HkAddComponent(_HKI("Add Symbol"), HK_ADD_NEW_COMPONENT, 'A', ID_PLACE_SYMBOL_TOOL)
static EDA_HOTKEY HkRotate(_HKI("Rotate Item"), HK_ROTATE, 'R')
static EDA_HOTKEY HkEndLineWireBus(_HKI("End Line Wire Bus"), HK_END_CURR_LINEWIREBUS, 'K')
static EDA_HOTKEY HkSwitchUnits(_HKI("Switch Units"), HK_SWITCH_UNITS, 'U'+GR_KB_CTRL)
#define GR_KB_SHIFT
static EDA_HOTKEY HkCanvasOpenGL(_HKI("Switch to Modern Toolset with hardware-accelerated graphics (recommended)"), HK_CANVAS_OPENGL, WXK_F11, ID_MENU_CANVAS_OPENGL)
static EDA_HOTKEY HkMouseLeftClick(_HKI("Mouse Left Click"), HK_LEFT_CLICK, WXK_RETURN, ID_MOUSE_CLICK)
static EDA_HOTKEY HkZoomRedraw(_HKI("Zoom Redraw"), HK_ZOOM_REDRAW, WXK_F3, ID_ZOOM_REDRAW)
static EDA_HOTKEY HkNew(_HKI("New"), HK_NEW, GR_KB_CTRL+ 'N', wxID_NEW)
static EDA_HOTKEY HkSaveAs(_HKI("Save As"), HK_SAVEAS, GR_KB_SHIFT+GR_KB_CTRL+ 'S', wxID_SAVEAS)
static EDA_HOTKEY HkEditCopy(_HKI("Copy"), HK_EDIT_COPY, GR_KB_CTRL+ 'C', wxID_COPY)
static EDA_HOTKEY HkShowDatasheet(_HKI("Show Symbol Datasheet"), HK_SHOW_COMPONENT_DATASHEET, 'D', ID_SCH_DISPLAYDOC_CMP)
static wxString commonSectionTitle(_HKI("Common"))
struct EDA_HOTKEY_CONFIG g_Libedit_Hotkeys_Descr[]
Definition: ee_hotkeys.cpp:407
static EDA_HOTKEY HkHighlightConnection(_HKI("Highlight Net"), ID_HOTKEY_HIGHLIGHT, 'B'+GR_KB_CTRL, ID_HIGHLIGHT_NET)
#define GR_KB_SHIFTCTRL
static EDA_HOTKEY HkBeginWire(_HKI("Begin Wire"), HK_BEGIN_WIRE, 'W', ID_WIRE_TOOL)
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
static EDA_HOTKEY HkDrag(_HKI("Drag Item"), HK_DRAG, 'G')
static EDA_HOTKEY HkInsertPin(_HKI("Repeat Pin"), HK_REPEAT_LAST, WXK_INSERT)
struct EDA_HOTKEY_CONFIG g_Schematic_Hotkeys_Descr[]
Definition: ee_hotkeys.cpp:398
static EDA_HOTKEY HkDuplicateItem(_HKI("Duplicate"), HK_DUPLICATE, 'D'+GR_KB_CTRL)
static EDA_HOTKEY HkAddHierarchicalLabel(_HKI("Add Hierarchical Label"), HK_ADD_HLABEL, 'H', ID_HIERLABEL_TOOL)
static EDA_HOTKEY HkZoomCenter(_HKI("Zoom Center"), HK_ZOOM_CENTER, WXK_F4, ID_POPUP_ZOOM_CENTER)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
static EDA_HOTKEY HkFindNextMarker(_HKI("Find Next Marker"), HK_FIND_NEXT_DRC_MARKER, WXK_F5+GR_KB_SHIFT, EVT_COMMAND_FIND_DRC_MARKER)
static EDA_HOTKEY HkEditPaste(_HKI("Paste"), HK_EDIT_PASTE, GR_KB_CTRL+ 'V', wxID_PASTE)
static EDA_HOTKEY HkFindItem(_HKI("Find Item"), HK_FIND_ITEM, 'F'+GR_KB_CTRL, ID_FIND_ITEMS)
static EDA_HOTKEY HkInsert(_HKI("Repeat Last Item"), HK_REPEAT_LAST, WXK_INSERT)
wxString g_CommonSectionTag
static EDA_HOTKEY HkLeaveSheet(_HKI("Leave Sheet"), HK_LEAVE_SHEET, GR_KB_ALT+WXK_BACK, ID_SCH_LEAVE_SHEET)
static EDA_HOTKEY HkSelectNode(_HKI("Select Node"), HK_SELECT_NODE, GR_KB_ALT+ '3', ID_HOTKEY_SELECT_NODE)
static EDA_HOTKEY HkCreatePin(_HKI("Create Pin"), HK_LIBEDIT_CREATE_PIN, 'P', ID_LIBEDIT_PIN_BUTT)
static EDA_HOTKEY HkAddWireEntry(_HKI("Add Wire Entry"), HK_ADD_WIRE_ENTRY, 'Z', ID_WIRETOBUS_ENTRY_TOOL)
static EDA_HOTKEY HkZoomIn(_HKI("Zoom In"), HK_ZOOM_IN, WXK_F1, ID_KEY_ZOOM_IN)
static EDA_HOTKEY HkUpdatePcbFromSch(_HKI("Update PCB from Schematic"), HK_UPDATE_PCB_FROM_SCH, WXK_F8, ID_UPDATE_PCB_FROM_SCH)
#define _HKI(x)
static EDA_HOTKEY HkAutoplaceFields(_HKI("Autoplace Fields"), HK_AUTOPLACE_FIELDS, 'O')
static EDA_HOTKEY HkResetLocalCoord(_HKI("Reset Local Coordinates"), HK_RESET_LOCAL_COORD, ' ')
int m_IdMenuEvent
Definition: hotkeys_basic.h:68
EDA_HOTKEY * GetDescriptorFromCommand(int aCommand, EDA_HOTKEY **aList)
Function GetDescriptorFromCommand Returns a EDA_HOTKEY* pointer from a hot key identifier.
static EDA_HOTKEY HkAddGraphicText(_HKI("Add Graphic Text"), HK_ADD_GRAPHIC_TEXT, 'T', ID_SCHEMATIC_TEXT_TOOL)
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
Definition: ee_hotkeys.cpp:423
static EDA_HOTKEY HkUnfoldBus(_HKI("Unfold from Bus"), HK_UNFOLD_BUS, 'C', ID_SCH_UNFOLD_BUS)
static EDA_HOTKEY HkViewDoc(_HKI("Show Datasheet"), HK_LIBEDIT_VIEW_DOC, 'D'+GR_KB_ALT, ID_LIBEDIT_VIEW_DOC)
static EDA_HOTKEY HkEditCut(_HKI("Cut"), HK_EDIT_CUT, GR_KB_CTRL+ 'X', wxID_CUT)