View Issue Details

IDProjectCategoryView StatusLast Update
0030137LazarusIDEpublic2018-06-06 00:41
ReportererrnoAssigned ToOndrej Pokorny 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformAMD 64OSwindows 64 bitsOS Version7
Product Version1.6Product Build 
Target Version1.6.2Fixed in Version1.7 (SVN) 
Summary0030137: RegisterIDEButtonCommand from unit ToolBarIntf does'nt link onClick event to the new toolbutton created
DescriptionExist also in SVN version (52304)

the folowing source code :

var IdeBtnCmd:TIDEButtonCommand;
    IdeCmd:TIDECommand;

IdeCmd:=RegisterIDECommand(IDECommandList.FindCategoryByName(CommandCategoryViewName),'MyIdeCmd','My IDE command',
                   @IdeCmdExecute);
IdeBtnCmd:=RegisterIDEButtonCommand(IDEToolButtonCategories.FindCategory(CommandCategoryViewName),'MyIdeBtnCmd',IdeCmd);

should add a new button on the toolbar but the IdeCmdExecute in never called . and the toolbutton does nothing .



Steps To ReproduceTry to add on new button on the source editor toolbar .
Tagsbutton, toolbar
Fixed in Revisionr52306
LazTarget1.6.2
Widgetset
Attached Files
  • testPakg.zip (1,517 bytes)
  • toolbarintf.patch (600 bytes)
    Index: components/ideintf/toolbarintf.pas
    ===================================================================
    --- components/ideintf/toolbarintf.pas	(revision 52304)
    +++ components/ideintf/toolbarintf.pas	(working copy)
    @@ -373,7 +373,12 @@
         Result := TIDEButtonCommand.Create(aName);
         FButtonNames.AddObject(aName, Result);
         aCategory.FButtons.Add(Result);
    -    Result.Command:=aCommand;
    +    if aCommand<>nil then with result do
    +      begin
    +      OnClick:=aCommand.OnExecute;
    +      OnClickProc:=aCommand.OnExecuteProc;
    +      end;
    +    result.Command:=aCommand;
       end;
     end;
     
    
    toolbarintf.patch (600 bytes)
  • toolbarintf2.patch (604 bytes)
    Index: components/ideintf/toolbarintf.pas
    ===================================================================
    --- components/ideintf/toolbarintf.pas	(revision 52304)
    +++ components/ideintf/toolbarintf.pas	(working copy)
    @@ -373,7 +373,12 @@
         Result := TIDEButtonCommand.Create(aName);
         FButtonNames.AddObject(aName, Result);
         aCategory.FButtons.Add(Result);
    -    Result.Command:=aCommand;
    +    if aCommand<>nil then with result do
    +      begin
    +        OnClick:=aCommand.OnExecute;
    +        OnClickProc:=aCommand.OnExecuteProc;
    +      end;
    +    result.Command:=aCommand;
       end;
     end;
     
    
    toolbarintf2.patch (604 bytes)
  • toolbarintf3.patch (601 bytes)
    Index: components/ideintf/toolbarintf.pas
    ===================================================================
    --- components/ideintf/toolbarintf.pas	(revision 52304)
    +++ components/ideintf/toolbarintf.pas	(working copy)
    @@ -373,7 +373,12 @@
         Result := TIDEButtonCommand.Create(aName);
         FButtonNames.AddObject(aName, Result);
         aCategory.FButtons.Add(Result);
    -    Result.Command:=aCommand;
    +    if aCommand<>nil then
    +    begin
    +      result.OnClick := aCommand.OnExecute;
    +      result.OnClickProc := aCommand.OnExecuteProc;
    +    end;
    +    result.Command := aCommand;
       end;
     end;
     
    
    toolbarintf3.patch (601 bytes)

Relationships

related to 0030143 closedOndrej Pokorny Useless peace of code 

Activities

errno

2016-05-14 18:05

reporter   ~0092565

Last edited: 2016-05-14 20:39

View 4 revisions

Joined a package example to install in IDE.

> the IdeCmdExecute in never called
you must read :
the IdeCmdExecute is never called

>Try to add on new button on the source editor toolbar
you must read :
Try to add a new button on the source editor toolbar

errno

2016-05-14 19:15

reporter  

testPakg.zip (1,517 bytes)

errno

2016-05-14 20:09

reporter  

toolbarintf.patch (600 bytes)
Index: components/ideintf/toolbarintf.pas
===================================================================
--- components/ideintf/toolbarintf.pas	(revision 52304)
+++ components/ideintf/toolbarintf.pas	(working copy)
@@ -373,7 +373,12 @@
     Result := TIDEButtonCommand.Create(aName);
     FButtonNames.AddObject(aName, Result);
     aCategory.FButtons.Add(Result);
-    Result.Command:=aCommand;
+    if aCommand<>nil then with result do
+      begin
+      OnClick:=aCommand.OnExecute;
+      OnClickProc:=aCommand.OnExecuteProc;
+      end;
+    result.Command:=aCommand;
   end;
 end;
 
toolbarintf.patch (600 bytes)

errno

2016-05-14 20:10

reporter   ~0092566

Last edited: 2016-05-14 20:10

View 2 revisions

patch added , fix the bug

errno

2016-05-14 21:55

reporter  

toolbarintf2.patch (604 bytes)
Index: components/ideintf/toolbarintf.pas
===================================================================
--- components/ideintf/toolbarintf.pas	(revision 52304)
+++ components/ideintf/toolbarintf.pas	(working copy)
@@ -373,7 +373,12 @@
     Result := TIDEButtonCommand.Create(aName);
     FButtonNames.AddObject(aName, Result);
     aCategory.FButtons.Add(Result);
-    Result.Command:=aCommand;
+    if aCommand<>nil then with result do
+      begin
+        OnClick:=aCommand.OnExecute;
+        OnClickProc:=aCommand.OnExecuteProc;
+      end;
+    result.Command:=aCommand;
   end;
 end;
 
toolbarintf2.patch (604 bytes)

errno

2016-05-14 21:56

reporter   ~0092568

Last edited: 2016-05-14 21:56

View 2 revisions

toolbarintf2.patch : patch 2nd version
changed indentation

Ondrej Pokorny

2016-05-14 22:02

reporter   ~0092571

1. please don't use with
2. use Delphi style indentation as described in http://wiki.freepascal.org/Coding_style#Lazarus

errno

2016-05-14 22:19

reporter  

toolbarintf3.patch (601 bytes)
Index: components/ideintf/toolbarintf.pas
===================================================================
--- components/ideintf/toolbarintf.pas	(revision 52304)
+++ components/ideintf/toolbarintf.pas	(working copy)
@@ -373,7 +373,12 @@
     Result := TIDEButtonCommand.Create(aName);
     FButtonNames.AddObject(aName, Result);
     aCategory.FButtons.Add(Result);
-    Result.Command:=aCommand;
+    if aCommand<>nil then
+    begin
+      result.OnClick := aCommand.OnExecute;
+      result.OnClickProc := aCommand.OnExecuteProc;
+    end;
+    result.Command := aCommand;
   end;
 end;
 
toolbarintf3.patch (601 bytes)

errno

2016-05-14 22:21

reporter   ~0092572

Last edited: 2016-05-14 22:23

View 2 revisions

changes done in toolbarintf3.patch

Ondrej Pokorny

2016-05-15 09:54

reporter   ~0092577

I fixed a little bit differently. Thanks anyway!

errno

2016-05-15 14:47

reporter   ~0092582

The way you fixed it , some code can be removed .
I have posted a report on it
http://mantis.freepascal.org/view.php?id=30143

Issue History

Date Modified Username Field Change
2016-05-14 17:14 errno New Issue
2016-05-14 18:05 errno Note Added: 0092565
2016-05-14 19:15 errno File Added: testPakg.zip
2016-05-14 19:29 errno Tag Attached: toolbar
2016-05-14 19:30 errno Tag Attached: button
2016-05-14 20:09 errno File Added: toolbarintf.patch
2016-05-14 20:10 errno Note Added: 0092566
2016-05-14 20:10 errno Note Edited: 0092566 View Revisions
2016-05-14 20:15 errno Note Edited: 0092565 View Revisions
2016-05-14 20:37 errno Note Edited: 0092565 View Revisions
2016-05-14 20:39 errno Note Edited: 0092565 View Revisions
2016-05-14 21:53 Ondrej Pokorny Assigned To => Ondrej Pokorny
2016-05-14 21:53 Ondrej Pokorny Status new => assigned
2016-05-14 21:55 errno File Added: toolbarintf2.patch
2016-05-14 21:56 errno Note Added: 0092568
2016-05-14 21:56 errno Note Edited: 0092568 View Revisions
2016-05-14 22:02 Ondrej Pokorny Note Added: 0092571
2016-05-14 22:19 errno File Added: toolbarintf3.patch
2016-05-14 22:21 errno Note Added: 0092572
2016-05-14 22:23 errno Note Edited: 0092572 View Revisions
2016-05-15 09:54 Ondrej Pokorny Fixed in Revision => r52306
2016-05-15 09:54 Ondrej Pokorny LazTarget => 1.6.2
2016-05-15 09:54 Ondrej Pokorny Widgetset Win32/Win64 =>
2016-05-15 09:54 Ondrej Pokorny Note Added: 0092577
2016-05-15 09:54 Ondrej Pokorny Status assigned => resolved
2016-05-15 09:54 Ondrej Pokorny Fixed in Version => 1.7 (SVN)
2016-05-15 09:54 Ondrej Pokorny Resolution open => fixed
2016-05-15 09:54 Ondrej Pokorny Target Version => 1.6.2
2016-05-15 14:47 errno Note Added: 0092582
2016-05-15 18:21 Ondrej Pokorny Relationship added related to 0030143
2018-06-06 00:41 errno Status resolved => closed