View Issue Details

IDProjectCategoryView StatusLast Update
0020140LazarusIDEpublic2015-12-28 20:55
Reportersilvioprog Assigned ToJuha Manninen  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.9.31 (SVN) 
Target Version1.2.0 
Summary0020140: FEATURE: Hotkeys for installation package window
DescriptionHi,

It would be nice to have keyboard shortcuts in the installation
package window. There are times we want to remove multiple entries of
the package, for example, the LCL of the package in screenshot below:

http://imagebin.org/170717

So, the default button to confirm the deletion is the "Yes", I could
use quickly Enter after Del, to remove the entries I want. That would
be very productive for those using a mouse pad.

Thx.

--
Silvio Cl├ęcio
TagsNo tags attached.
Fixed in Revisionr43631, r43634
LazTarget1.2
Widgetset
Attached Files

Relationships

related to 0019363 assignedJuha Manninen Hotkeys in Package viewer 

Activities

2011-09-06 02:00

 

menuintf.pas.patch (3,665 bytes)   
Index: menuintf.pas
===================================================================
--- menuintf.pas	(revision 32190)
+++ menuintf.pas	(working copy)
@@ -57,6 +57,7 @@
     FResourceName: String;
     FSection: TIDEMenuSection;
     FSectionIndex: Integer;
+    FShortCut: TShortCut;
     FSize: integer;
     FTag: Integer;
     FVisible: Boolean;
@@ -114,6 +115,7 @@
     property SectionIndex: Integer read FSectionIndex;
     property AutoFreeMenuItem: boolean read FAutoFreeMenuItem write FAutoFreeMenuItem;
     property ResourceName: String read FResourceName write SetResourceName;
+    property ShortCut: TShortCut read FShortCut write FShortCut;
     property Tag: Integer read FTag write FTag;
   end;
   TIDEMenuItemClass = class of TIDEMenuItem;
@@ -456,13 +458,15 @@
                                 const OnClickMethod: TNotifyEvent = nil;
                                 const OnClickProc: TNotifyProcedure = nil;
                                 const Command: TIDECommand = nil;
-                                const ResourceName: String = ''
+                                const ResourceName: String = '';
+                                const ShortCut: TShortCut = 0
                                 ): TIDEMenuCommand; overload;
 function RegisterIDEMenuCommand(const Path, Name, Caption: string;
                                 const OnClickMethod: TNotifyEvent = nil;
                                 const OnClickProc: TNotifyProcedure = nil;
                                 const Command: TIDECommand = nil;
-                                const ResourceName: String = ''
+                                const ResourceName: String = '';
+                                const ShortCut: TShortCut = 0
                                 ): TIDEMenuCommand; overload;
 
 implementation
@@ -524,7 +528,8 @@
                                 const OnClickMethod: TNotifyEvent = nil;
                                 const OnClickProc: TNotifyProcedure = nil;
                                 const Command: TIDECommand = nil;
-                                const ResourceName: String = ''
+                                const ResourceName: String = '';
+                                const ShortCut: TShortCut = 0
                                 ): TIDEMenuCommand;
 begin
   Result := TIDEMenuCommand.Create(Name);
@@ -533,6 +538,7 @@
   Result.OnClickProc := OnClickProc;
   Result.Command := Command;
   Result.ResourceName := ResourceName;
+  Result.ShortCut := ShortCut;
   Parent.AddLast(Result);
 end;
 
@@ -540,7 +546,8 @@
                                 const OnClickMethod: TNotifyEvent = nil;
                                 const OnClickProc: TNotifyProcedure = nil;
                                 const Command: TIDECommand = nil;
-                                const ResourceName: String = ''
+                                const ResourceName: String = '';
+                                const ShortCut: TShortCut = 0
                                 ): TIDEMenuCommand;
 var
   Parent: TIDEMenuSection;
@@ -548,7 +555,7 @@
   //debugln('RegisterIDEMenuCommand Path="',Path,'" Name="',Name,'"');
   Parent := IDEMenuRoots.FindByPath(Path,true) as TIDEMenuSection;
   Result := RegisterIDEMenuCommand(Parent, Name, Caption,
-    OnClickMethod, OnClickProc, Command, ResourceName);
+    OnClickMethod, OnClickProc, Command, ResourceName, ShortCut);
 end;
 
 { TIDEMenuItem }
@@ -788,6 +795,7 @@
   //debugln('TIDEMenuItem.CreateMenuItem ',dbgsName(Self),' Name="',Name,'"');
   {$ENDIF}
   MenuItem:=MenuItemClass.Create(nil);
+  MenuItem.ShortCut:=ShortCut;
   AutoFreeMenuItem:=true;
 end;
 
menuintf.pas.patch (3,665 bytes)   

2011-09-06 02:00

 

packageeditor.pas.patch (5,971 bytes)   
Index: packageeditor.pas
===================================================================
--- packageeditor.pas	(revision 32190)
+++ packageeditor.pas	(working copy)
@@ -424,11 +424,11 @@
   // register the section for operations on single files
   PkgEditMenuSectionFile:=RegisterIDEMenuSection(PackageEditorMenuRoot,'File');
   AParent:=PkgEditMenuSectionFile;
-  PkgEditMenuOpenFile:=RegisterIDEMenuCommand(AParent,'Open File',lisOpenFile);
+  PkgEditMenuOpenFile:=RegisterIDEMenuCommand(AParent,'Open File',lisOpenFile,nil,nil,nil,'',ShortCut(Ord('O'),[ssCtrl]));
   PkgEditMenuRemoveFile:=RegisterIDEMenuCommand(AParent,'Remove File',lisPckEditRemoveFile);
   PkgEditMenuReAddFile:=RegisterIDEMenuCommand(AParent,'ReAdd File',lisPckEditReAddFile);
-  PkgEditMenuMoveFileUp:=RegisterIDEMenuCommand(AParent,'Move File Up',lisPEMoveFileUp);
-  PkgEditMenuMoveFileDown:=RegisterIDEMenuCommand(AParent,'Move File Down',lisPEMoveFileDown);
+  PkgEditMenuMoveFileUp:=RegisterIDEMenuCommand(AParent,'Move File Up',lisPEMoveFileUp,nil,nil,nil,'',ShortCut(VK_UP,[ssCtrl]));
+  PkgEditMenuMoveFileDown:=RegisterIDEMenuCommand(AParent,'Move File Down',lisPEMoveFileDown,nil,nil,nil,'',ShortCut(VK_DOWN,[ssCtrl]));
   PkgEditMenuEditVirtualUnit:=RegisterIDEMenuCommand(AParent,'Edit Virtual File',lisPEEditVirtualUnit);
   PkgEditMenuSectionFileType:=RegisterIDESubMenu(AParent,'File Type',lisAF2PFileType);
 
@@ -463,30 +463,30 @@
   PkgEditMenuSectionUse:=RegisterIDEMenuSection(PackageEditorMenuRoot,'Use');
   AParent:=PkgEditMenuSectionUse;
   PkgEditMenuAddToProject:=RegisterIDEMenuCommand(AParent,'Add To Project',lisPckEditAddToProject);
-  PkgEditMenuInstall:=RegisterIDEMenuCommand(AParent,'Install',lisPckEditInstall);
-  PkgEditMenuUninstall:=RegisterIDEMenuCommand(AParent,'Uninstall',lisPckEditUninstall);
+  PkgEditMenuInstall:=RegisterIDEMenuCommand(AParent,'Install',lisPckEditInstall,nil,nil,nil,'',ShortCut(Ord('I'),[ssCtrl]));
+  PkgEditMenuUninstall:=RegisterIDEMenuCommand(AParent,'Uninstall',lisPckEditUninstall,nil,nil,nil,'',ShortCut(Ord('U'),[ssCtrl]));
 
   // register the section for saving the package
   PkgEditMenuSectionSave:=RegisterIDEMenuSection(PackageEditorMenuRoot,'Save');
   AParent:=PkgEditMenuSectionSave;
-  PkgEditMenuSave:=RegisterIDEMenuCommand(AParent, 'Save', lisPckEditSavePackage);
-  PkgEditMenuSaveAs:=RegisterIDEMenuCommand(AParent, 'Save As', lisPESavePackageAs);
-  PkgEditMenuRevert:=RegisterIDEMenuCommand(AParent, 'Revert', lisPERevertPackage);
-  PkgEditMenuPublish:=RegisterIDEMenuCommand(AParent,'Publish',lisPkgEditPublishPackage);
+  PkgEditMenuSave:=RegisterIDEMenuCommand(AParent, 'Save', lisPckEditSavePackage,nil,nil,nil,'',ShortCut(Ord('S'),[ssCtrl]));
+  PkgEditMenuSaveAs:=RegisterIDEMenuCommand(AParent, 'Save As', lisPESavePackageAs,nil,nil,nil,'',ShortCut(Ord('O'),[ssShift,ssCtrl]));
+  PkgEditMenuRevert:=RegisterIDEMenuCommand(AParent, 'Revert', lisPERevertPackage,nil,nil,nil,'',ShortCut(Ord('Z'),[ssCtrl]));
+  PkgEditMenuPublish:=RegisterIDEMenuCommand(AParent,'Publish',lisPkgEditPublishPackage,nil,nil,nil,'',ShortCut(Ord('P'),[ssShift,ssCtrl]));
 
   // register the section for compiling the package
   PkgEditMenuSectionCompile:=RegisterIDEMenuSection(PackageEditorMenuRoot,'Compile');
   AParent:=PkgEditMenuSectionCompile;
-  PkgEditMenuCompile:=RegisterIDEMenuCommand(AParent,'Compile',lisPckEditCompile);
-  PkgEditMenuRecompileClean:=RegisterIDEMenuCommand(AParent,'Recompile Clean',lisPckEditRecompileClean);
+  PkgEditMenuCompile:=RegisterIDEMenuCommand(AParent,'Compile',lisPckEditCompile,nil,nil,nil,'',ShortCut(VK_F9,[ssCtrl]));
+  PkgEditMenuRecompileClean:=RegisterIDEMenuCommand(AParent,'Recompile Clean',lisPckEditRecompileClean,nil,nil,nil,'',ShortCut(VK_F,[ssShift,ssCtrl]));
   PkgEditMenuRecompileAllRequired:=RegisterIDEMenuCommand(AParent,'Recompile All Required',lisPckEditRecompileAllRequired);
   PkgEditMenuCreateMakefile:=RegisterIDEMenuCommand(AParent,'Create Makefile',lisPckEditCreateMakefile);
 
   // register the section for adding to or removing from package
   PkgEditMenuSectionAddRemove:=RegisterIDEMenuSection(PackageEditorMenuRoot,'AddRemove');
   AParent:=PkgEditMenuSectionCompile;
-  PkgEditMenuAdd:=RegisterIDEMenuCommand(AParent,'Add',lisCodeTemplAdd);
-  PkgEditMenuRemove:=RegisterIDEMenuCommand(AParent,'Remove',lisExtToolRemove);
+  PkgEditMenuAdd:=RegisterIDEMenuCommand(AParent,'Add',lisCodeTemplAdd,nil,nil,nil,'',ShortCut(VK_INSERT,[ssCtrl]));
+  PkgEditMenuRemove:=RegisterIDEMenuCommand(AParent,'Remove',lisExtToolRemove,nil,nil,nil,'',ShortCut(VK_DELETE,[]));
 
   // register the section for other things
   PkgEditMenuSectionMisc:=RegisterIDEMenuSection(PackageEditorMenuRoot,'Misc');
@@ -700,7 +700,7 @@
   ItemCnt: Integer;
 
   function AddPopupMenuItem(const ACaption: string; AnEvent: TNotifyEvent;
-    EnabledFlag: boolean): TMenuItem;
+    EnabledFlag: boolean; AShortCut: TShortCut): TMenuItem;
   begin
     if UsePopupMenu.Items.Count<=ItemCnt then begin
       Result:=TMenuItem.Create(Self);
@@ -712,6 +712,7 @@
     Result.Caption:=ACaption;
     Result.OnClick:=AnEvent;
     Result.Enabled:=EnabledFlag;
+    Result.ShortCut:=AShortCut;
     inc(ItemCnt);
   end;
 
@@ -719,10 +720,12 @@
   ItemCnt:=0;
 
   AddPopupMenuItem(lisPckEditAddToProject, @AddToProjectClick,
-                   CanBeAddedToProject);
-  AddPopupMenuItem(lisPckEditInstall, @InstallClick,not LazPackage.AutoCreated);
+                   CanBeAddedToProject,0);
+  AddPopupMenuItem(lisPckEditInstall, @InstallClick,not LazPackage.AutoCreated,
+                   ShortCut(Ord('I'),[ssCtrl]));
   AddPopupMenuItem(lisPckEditUninstall, @UninstallClick,
-          (LazPackage.Installed<>pitNope) or (LazPackage.AutoInstall<>pitNope));
+          (LazPackage.Installed<>pitNope) or (LazPackage.AutoInstall<>pitNope),
+          ShortCut(Ord('U'),[ssCtrl]));
 
   // remove unneeded menu items
   while UsePopupMenu.Items.Count>ItemCnt do
packageeditor.pas.patch (5,971 bytes)   

silvioprog

2011-09-06 02:00

reporter   ~0051494

Patches in attached.

2011-09-06 02:19

 

silvioprog

2011-09-06 02:19

reporter   ~0051495

Oops, please see only "packageeditor.pas.patch-2".

Thx.

Juha Manninen

2011-10-08 09:35

developer   ~0052769

IMO the patch is not correct. Lazarus connects shortcuts to commands, not to menu items, and manages them in a centralized way.

silvioprog

2011-10-09 01:10

reporter   ~0052790

Hellow Juha. :)

If you prefer, I can make a patch using ActionList.

Juha Manninen

2011-10-09 13:07

developer   ~0052799

No Silvio, actions don't help here. You must use TIDECommand (actually TIDEMenuCommand) like rest of the IDE does.
At least you must not modify RegisterIDEMenuCommand in MenuIntf like you did. You bypassed the Command parameter and added your own shortcut.

See IDECommands unit. You must define new commands there to be used in Package Editor. Default shortcuts are defined in unit KeyMapping, in GetDefaultKeyForWindowsScheme and other similar funcs.
User can change the shortcuts later in Options dialog.
You must study how the other commands are mapped, quite many places in code must be updated. I had to study it well when I changed Lazarus menu structures.

You will have a question if you could reuse existing commands? In practice you can't reuse them much. Package Editor is a modeless (floating) window and the commands should not clash with other IDE commands. For example your Ctrl-O shortcut does not work because it is already used.
Source Editor defines its own commands which can't be reused.

Another question is if you need the commands at all? If you have a menu and want a shortcut there, then you need the command, yes.
However, many windows don't have menus but they have buttons (eg. Up and Down buttons) and grab keys like VK_UP and VK_DOWN themselves.

A big advantage of commands is that the user can change their shortcuts.
Your idea of having shortcuts is good. I personally think there are too many items in the popup menu but the shortcuts make it better.

As it seems you are willing to make patches:
please make them from the Lazarus source root directory and include all changed files to the same patch. Like:
$ svn diff packager/packageeditor.pas ideintf/menuintf.pas > mypatch.patch
I also happily accept git format patches in case you want to work with local git branches.

Vincent Snijders

2011-10-10 16:52

manager   ~0052834

Updated target version, because of missing (valid) patch.

Juha Manninen

2014-01-02 19:31

developer   ~0072177

I added Delete and Insert shortcut keys for package editor.
I also fixed another bug that prevented Up/Down keys working.

The other shortcut keys in your patch must not be hard-coded because they may conflict with global IDE keymappings.
Also we should not make these package editor commands global because they take effect only when the package editor is active.

I think this solution is as good as it gets with the current (less than perfect) IDE command system.
The changes are backported to Lazarus 1.2.

silvioprog

2014-10-31 03:43

reporter   ~0078767

Very nice!

Seems nice to add hints showing the shortcuts (please see "hint.png" in attached).

silvioprog

2014-10-31 03:44

reporter  

hint.png (47,762 bytes)   
hint.png (47,762 bytes)   

silvioprog

2015-12-28 20:55

reporter   ~0088363

Fixed, thank you!

Issue History

Date Modified Username Field Change
2011-09-02 23:23 silvioprog New Issue
2011-09-06 02:00 silvioprog File Added: menuintf.pas.patch
2011-09-06 02:00 silvioprog File Added: packageeditor.pas.patch
2011-09-06 02:00 silvioprog Note Added: 0051494
2011-09-06 02:19 silvioprog File Added: packageeditor.pas.patch-2
2011-09-06 02:19 silvioprog Note Added: 0051495
2011-10-07 14:39 Vincent Snijders LazTarget => 0.99.0
2011-10-07 14:39 Vincent Snijders Status new => acknowledged
2011-10-07 14:39 Vincent Snijders Target Version => 0.99.0
2011-10-08 09:35 Juha Manninen Note Added: 0052769
2011-10-08 23:08 Juha Manninen Relationship added related to 0019363
2011-10-09 01:10 silvioprog Note Added: 0052790
2011-10-09 13:07 Juha Manninen Note Added: 0052799
2011-10-09 13:12 Juha Manninen Status acknowledged => assigned
2011-10-09 13:12 Juha Manninen Assigned To => Juha Manninen
2011-10-10 16:52 Vincent Snijders LazTarget 0.99.0 => 1.2
2011-10-10 16:52 Vincent Snijders Note Added: 0052834
2011-10-10 16:52 Vincent Snijders Target Version 0.99.0 => 1.2.0
2014-01-02 19:31 Juha Manninen Fixed in Revision => r43631, r43634
2014-01-02 19:31 Juha Manninen Note Added: 0072177
2014-01-02 19:31 Juha Manninen Status assigned => resolved
2014-01-02 19:31 Juha Manninen Resolution open => fixed
2014-10-31 03:43 silvioprog Note Added: 0078767
2014-10-31 03:44 silvioprog File Added: hint.png
2015-12-28 20:55 silvioprog Note Added: 0088363
2015-12-28 20:55 silvioprog Status resolved => closed