View Issue Details

IDProjectCategoryView StatusLast Update
0023846LazarusLCLpublic2013-02-11 08:55
ReporterImantsAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformAllOSOS Version
Product Version1.1 (SVN)Product Build 
Target VersionFixed in Version1.1 (SVN) 
Summary0023846: TValueListEditor OnEditButtonClick do not work
DescriptionI create TItemProp with EditStyle esEllipsis and assign TValueListEditor method OnEditButtonClick, but when I click the button nothing happens.
TagsNo tags attached.
Fixed in Revisionr40227, r40242
LazTarget-
Widgetset
Attached Files
  • button.rar (3,533 bytes)
  • valedit.patch (2,984 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 40224)
    +++ lcl/grids.pas	(working copy)
    @@ -278,6 +278,8 @@
         FEditors: array of TEditorItem;
         procedure DispatchMsg(msg: TGridMessage);
         function GetActiveControl: TWinControl;
    +    function GetEditorCount: Integer;
    +    function GetEditors(index: Integer): TWinControl;
         function GetMaxLength: Integer;
         procedure SetMaxLength(AValue: Integer);
       protected
    @@ -299,6 +301,8 @@
         procedure AddEditor(aEditor: TWinControl; aAlign: TAlign; ActiveCtrl:boolean);
         procedure SetFocus; override;
         property MaxLength: Integer read GetMaxLength write SetMaxLength;
    +    property EditorCount: Integer read GetEditorCount;
    +    property Editors[index: Integer]: TWinControl read GetEditors;
       end;
     
     
    @@ -11835,6 +11839,16 @@
         end;
     end;
     
    +function TCompositeCellEditor.GetEditorCount: Integer;
    +begin
    +  Result := Length(FEditors);
    +end;
    +
    +function TCompositeCellEditor.GetEditors(index: Integer): TWinControl;
    +begin
    +  Result := FEditors[index].Editor;
    +end;
    +
     procedure TCompositeCellEditor.msg_GetValue(var Msg: TGridMessage);
     var
       i: Integer;
    Index: lcl/valedit.pas
    ===================================================================
    --- lcl/valedit.pas	(revision 40224)
    +++ lcl/valedit.pas	(working copy)
    @@ -119,6 +119,7 @@
         procedure SetOptions(const AValue: TGridOptions);
         procedure SetStrings(const AValue: TValueListStrings);
         procedure SetTitleCaptions(const AValue: TStrings);
    +    procedure DoOnEditButtonClick(Sender: TObject);
       protected
         class procedure WSRegisterClass; override;
         procedure DoOnResize; override;
    @@ -587,6 +588,7 @@
     // Choose the cell editor based on ItemProp.EditStyle
     var
       ItemProp: TItemProp;
    +  i: Integer;
     begin
       if aCol <> 1 then Exit;     // Only for the Value column
       ItemProp := nil;
    @@ -595,7 +597,16 @@
       if Assigned(ItemProp) then
         case ItemProp.EditStyle of
           esSimple: aEditor := EditorByStyle(cbsAuto);
    -      esEllipsis: aEditor := EditorByStyle(cbsEllipsis);
    +      esEllipsis:
    +      begin
    +        aEditor := EditorByStyle(cbsEllipsis);
    +        for i := 0 to (aEditor as TCompositeCellEditor).EditorCount - 1 do
    +          if (aEditor as TCompositeCellEditor).Editors[i] is TCustomButton then
    +          begin
    +            ((aEditor as TCompositeCellEditor).Editors[i] as TCustomButton).OnClick := @DoOnEditButtonClick;
    +            Break;
    +          end;
    +      end;
           esPickList: begin
             aEditor := EditorByStyle(cbsPickList);
             (aEditor as TCustomComboBox).Items.Assign(ItemProp.PickList);
    @@ -700,6 +711,12 @@
       FTitleCaptions.Assign(AValue);
     end;
     
    +procedure TValueListEditor.DoOnEditButtonClick(Sender: TObject);
    +begin
    +  if Assigned(FOnEditButtonClick) then
    +    FOnEditButtonClick(Self);
    +end;
    +
     function TValueListEditor.GetKey(Index: Integer): string;
     begin
       Result:=Cells[0,Index];
    
    valedit.patch (2,984 bytes)

Activities

Imants

2013-02-07 08:14

reporter  

button.rar (3,533 bytes)

Imants

2013-02-07 12:10

reporter   ~0065537

Last edited: 2013-02-07 12:22

View 2 revisions

I messed up.
attached file "rttictrls.pas" and last comment was meant for this report

http://bugs.freepascal.org/view.php?id=23848

Juha Manninen

2013-02-09 13:02

developer   ~0065597

The esEllipsis feature is not implemented yet. Patches are welcome.

Bart Broersma

2013-02-09 14:33

developer   ~0065600

@Imants: I deleted the notes and attachments that (as by you) weren't meant for this report.

Imants

2013-02-09 15:44

reporter   ~0065603

I can try to implement these features how can I create patch if I succeed?

Imants

2013-02-09 16:18

reporter  

valedit.patch (2,984 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 40224)
+++ lcl/grids.pas	(working copy)
@@ -278,6 +278,8 @@
     FEditors: array of TEditorItem;
     procedure DispatchMsg(msg: TGridMessage);
     function GetActiveControl: TWinControl;
+    function GetEditorCount: Integer;
+    function GetEditors(index: Integer): TWinControl;
     function GetMaxLength: Integer;
     procedure SetMaxLength(AValue: Integer);
   protected
@@ -299,6 +301,8 @@
     procedure AddEditor(aEditor: TWinControl; aAlign: TAlign; ActiveCtrl:boolean);
     procedure SetFocus; override;
     property MaxLength: Integer read GetMaxLength write SetMaxLength;
+    property EditorCount: Integer read GetEditorCount;
+    property Editors[index: Integer]: TWinControl read GetEditors;
   end;
 
 
@@ -11835,6 +11839,16 @@
     end;
 end;
 
+function TCompositeCellEditor.GetEditorCount: Integer;
+begin
+  Result := Length(FEditors);
+end;
+
+function TCompositeCellEditor.GetEditors(index: Integer): TWinControl;
+begin
+  Result := FEditors[index].Editor;
+end;
+
 procedure TCompositeCellEditor.msg_GetValue(var Msg: TGridMessage);
 var
   i: Integer;
Index: lcl/valedit.pas
===================================================================
--- lcl/valedit.pas	(revision 40224)
+++ lcl/valedit.pas	(working copy)
@@ -119,6 +119,7 @@
     procedure SetOptions(const AValue: TGridOptions);
     procedure SetStrings(const AValue: TValueListStrings);
     procedure SetTitleCaptions(const AValue: TStrings);
+    procedure DoOnEditButtonClick(Sender: TObject);
   protected
     class procedure WSRegisterClass; override;
     procedure DoOnResize; override;
@@ -587,6 +588,7 @@
 // Choose the cell editor based on ItemProp.EditStyle
 var
   ItemProp: TItemProp;
+  i: Integer;
 begin
   if aCol <> 1 then Exit;     // Only for the Value column
   ItemProp := nil;
@@ -595,7 +597,16 @@
   if Assigned(ItemProp) then
     case ItemProp.EditStyle of
       esSimple: aEditor := EditorByStyle(cbsAuto);
-      esEllipsis: aEditor := EditorByStyle(cbsEllipsis);
+      esEllipsis:
+      begin
+        aEditor := EditorByStyle(cbsEllipsis);
+        for i := 0 to (aEditor as TCompositeCellEditor).EditorCount - 1 do
+          if (aEditor as TCompositeCellEditor).Editors[i] is TCustomButton then
+          begin
+            ((aEditor as TCompositeCellEditor).Editors[i] as TCustomButton).OnClick := @DoOnEditButtonClick;
+            Break;
+          end;
+      end;
       esPickList: begin
         aEditor := EditorByStyle(cbsPickList);
         (aEditor as TCustomComboBox).Items.Assign(ItemProp.PickList);
@@ -700,6 +711,12 @@
   FTitleCaptions.Assign(AValue);
 end;
 
+procedure TValueListEditor.DoOnEditButtonClick(Sender: TObject);
+begin
+  if Assigned(FOnEditButtonClick) then
+    FOnEditButtonClick(Self);
+end;
+
 function TValueListEditor.GetKey(Index: Integer): string;
 begin
   Result:=Cells[0,Index];
valedit.patch (2,984 bytes)

Imants

2013-02-09 16:18

reporter   ~0065605

I found turtorial how to create patches. So here is my posible solution

Bart Broersma

2013-02-09 17:57

developer   ~0065607

Please close if OK, otherwise re-open.

Imants

2013-02-09 19:02

reporter   ~0065612

OnEditButtonClick started to work, but it become unpublished after your change

Bart Broersma

2013-02-10 13:42

developer   ~0065619

Published OnButtonClick and OnEditButtonClick in r40242.
Please close if OK.

Imants

2013-02-11 08:55

reporter   ~0065631

it works now

Issue History

Date Modified Username Field Change
2013-02-07 08:14 Imants New Issue
2013-02-07 08:14 Imants File Added: button.rar
2013-02-07 11:56 Imants File Added: rttictrls.pas
2013-02-07 12:10 Imants Note Added: 0065537
2013-02-07 12:22 Imants Note Edited: 0065537 View Revisions
2013-02-09 13:02 Juha Manninen Note Added: 0065597
2013-02-09 14:33 Bart Broersma Note Added: 0065600
2013-02-09 14:33 Bart Broersma File Deleted: rttictrls.pas
2013-02-09 15:44 Imants Note Added: 0065603
2013-02-09 16:18 Imants File Added: valedit.patch
2013-02-09 16:18 Imants Note Added: 0065605
2013-02-09 17:57 Bart Broersma Fixed in Revision => r40227
2013-02-09 17:57 Bart Broersma LazTarget => -
2013-02-09 17:57 Bart Broersma Note Added: 0065607
2013-02-09 17:57 Bart Broersma Status new => resolved
2013-02-09 17:57 Bart Broersma Fixed in Version => 1.1 (SVN)
2013-02-09 17:57 Bart Broersma Resolution open => fixed
2013-02-09 17:57 Bart Broersma Assigned To => Bart Broersma
2013-02-09 19:02 Imants Note Added: 0065612
2013-02-09 19:02 Imants Status resolved => assigned
2013-02-09 19:02 Imants Resolution fixed => reopened
2013-02-10 13:42 Bart Broersma Fixed in Revision r40227 => r40227, r40242
2013-02-10 13:42 Bart Broersma Note Added: 0065619
2013-02-10 13:42 Bart Broersma Status assigned => resolved
2013-02-10 13:42 Bart Broersma Resolution reopened => fixed
2013-02-11 08:55 Imants Note Added: 0065631
2013-02-11 08:55 Imants Status resolved => closed