ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/ibcontrols/IBLookupComboEditBox.pas
(Generate patch)

Comparing ibx/trunk/ibcontrols/IBLookupComboEditBox.pas (file contents):
Revision 263 by tony, Thu Dec 6 15:55:01 2018 UTC vs.
Revision 275 by tony, Mon Feb 4 13:41:10 2019 UTC

# Line 54 | Line 54 | type
54      FOwner: TIBLookupComboEditBox;
55    protected
56      procedure ActiveChanged; override;
57 +    {$if lcl_fullversion < 2000003}
58      procedure DataEvent(Event: TDataEvent; Info: Ptrint); override;
59 +    {$endif}
60      procedure RecordChanged(Field: TField); override;
61      procedure UpdateData; override;
62    public
# Line 117 | Line 119 | type
119      procedure CheckAndInsert;
120      procedure DoEnter; override;
121      procedure DoExit; override;
122 <    {$if lcl_fullversion >= 2000000}
122 >    {$if lcl_fullversion >= 2000002}
123      {Deferred update changes in Lazarus 2.0 stop the combo box working when
124       the datasource is nil. We thus have to reverse out the changes :(}
125      function DoEdit: boolean; override;
126      procedure Change; override;
127      procedure CloseUp; override;
128      procedure Select; override;
127    procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
129      {$ifend}
130      procedure KeyUp(var Key: Word; Shift: TShiftState); override;
131      procedure Loaded; override;
132      procedure Notification(AComponent: TComponent; Operation: TOperation); override;
133      procedure SetItemIndex(const Val: integer); override;
133    function SQLSafe(aText: string): string;
134      procedure UpdateShowing; override;
135      procedure UpdateData(Sender: TObject); override;
136    public
# Line 156 | Line 156 | type
156  
157   implementation
158  
159 < uses Variants, LCLProc, LazUTF8;
159 > uses Variants, LCLProc, LazUTF8, IBUtils;
160  
161   { TIBLookupControlLink }
162  
# Line 178 | Line 178 | begin
178    FOwner.ActiveChanged(self)
179   end;
180  
181 + {$if lcl_fullversion < 2000003}
182   procedure TIBLookupComboDataLink.DataEvent(Event: TDataEvent; Info: Ptrint);
183   begin
184    inherited DataEvent(Event, Info);
185    if Event = deLayoutChange then
186     FOwner.LookupCache := FOwner.LookupCache; {sneaky way of calling UpdateLookup}
187   end;
188 + {$endif}
189  
190   procedure TIBLookupComboDataLink.RecordChanged(Field: TField);
191   begin
# Line 393 | Line 395 | begin
395        FilterText := Text;
396      if cbactSearchCaseSensitive in AutoCompleteText then
397        Parser.Add2WhereClause(GetRelationNameQualifier + '"' + ListField + '" Like ''' +
398 <                                  SQLSafe(FilterText) + '%''')
398 >                                  SQLSafeString(FilterText) + '%''')
399      else
400        Parser.Add2WhereClause('Upper(' + GetRelationNameQualifier + '"' +  ListField + '") Like Upper(''' +
401 <                                  SQLSafe(FilterText) + '%'')');
401 >                                  SQLSafeString(FilterText) + '%'')');
402  
403      if cbactSearchAscending in AutoCompleteText then
404      begin
# Line 561 | Line 563 | begin
563    FLastKeyValue := KeyValue;
564   end;
565  
564 function TIBLookupComboEditBox.SQLSafe(aText: string): string;
565 var I: integer;
566 begin
567  Result := '';
568  for I := 1 to length(aText) do
569    if aText[I] = '''' then
570      Result := Result + ''''''
571    else
572      Result := Result + aText[I];
573 end;
574
566   procedure TIBLookupComboEditBox.UpdateShowing;
567   begin
568    inherited UpdateShowing;
# Line 587 | Line 578 | begin
578    FModified := false;
579   end;
580  
581 < {$if lcl_fullversion >= 2000000}
581 > {$if lcl_fullversion >= 2000002}
582   type
583  
584    { THackedCustomComboBox }
585  
586    THackedCustomComboBox = class(TCustomComboBox)
587    private
597    procedure CallUTF8KeyPress(var UTF8Key: TUTF8Char);
588      procedure CallChange;
589    end;
590  
591   { THackedCustomComboBox }
592  
603 procedure THackedCustomComboBox.CallUTF8KeyPress(var UTF8Key: TUTF8Char);
604 begin
605  inherited UTF8KeyPress(UTF8Key);
606 end;
607
593   procedure THackedCustomComboBox.CallChange;
594   begin
595    inherited Change;
596   end;
597  
613 procedure TIBLookupComboEditBox.UTF8KeyPress(var UTF8Key: TUTF8Char);
614 begin
615  {TDBLookupComboBox.UTF8KeyPress will swallow the character if
616  the datalink is not editable. hence to enable writing we must override it}
617  if ((DataSource = nil) or (Field = nil)) and not ReadOnly then
618    THackedCustomComboBox(self).CallUTF8KeyPress(UTF8Key)
619  else
620    inherited;
621 end;
622
598   procedure TIBLookupComboEditBox.Change;
599   begin
600 <  THackedCustomComboBox(self).CallChange;
600 >  if DataSource = nil then
601 >    THackedCustomComboBox(self).CallChange
602 >  else
603 >    inherited Change;
604   end;
605  
606   procedure TIBLookupComboEditBox.CloseUp;
607   begin
630  inherited CloseUp;
608    inherited DoEdit;
609 +  inherited CloseUp;
610 +  EditingDone;
611   end;
612  
613   procedure TIBLookupComboEditBox.Select;
614   begin
615    inherited Select;
616 <  inherited DoEdit;
616 >  if DataSource = nil then
617 >    inherited DoEdit;
618   end;
619  
620   function TIBLookupComboEditBox.DoEdit: boolean;
621   begin
622    {DoEdit will swallow characters if no editable Field. Hence, to enabled
623     writing we must avoid calling the inherited method.}
624 <  if ((DataSource = nil) or (Field = nil)) and not ReadOnly then
624 >  if DataSource = nil then
625      Result := true
626    else
627      Result := inherited DoEdit;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines