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 276 by tony, Mon Feb 4 13:43:20 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;
129 +    {$ifend}
130 +    {$if lcl_fullversion = 2000002}
131      procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
132      {$ifend}
133      procedure KeyUp(var Key: Word; Shift: TShiftState); override;
134      procedure Loaded; override;
135      procedure Notification(AComponent: TComponent; Operation: TOperation); override;
136      procedure SetItemIndex(const Val: integer); override;
133    function SQLSafe(aText: string): string;
137      procedure UpdateShowing; override;
138      procedure UpdateData(Sender: TObject); override;
139    public
# Line 156 | Line 159 | type
159  
160   implementation
161  
162 < uses Variants, LCLProc, LazUTF8;
162 > uses Variants, LCLProc, LazUTF8, IBUtils;
163  
164   { TIBLookupControlLink }
165  
# Line 178 | Line 181 | begin
181    FOwner.ActiveChanged(self)
182   end;
183  
184 + {$if lcl_fullversion < 2000003}
185   procedure TIBLookupComboDataLink.DataEvent(Event: TDataEvent; Info: Ptrint);
186   begin
187    inherited DataEvent(Event, Info);
188    if Event = deLayoutChange then
189     FOwner.LookupCache := FOwner.LookupCache; {sneaky way of calling UpdateLookup}
190   end;
191 + {$endif}
192  
193   procedure TIBLookupComboDataLink.RecordChanged(Field: TField);
194   begin
# Line 393 | Line 398 | begin
398        FilterText := Text;
399      if cbactSearchCaseSensitive in AutoCompleteText then
400        Parser.Add2WhereClause(GetRelationNameQualifier + '"' + ListField + '" Like ''' +
401 <                                  SQLSafe(FilterText) + '%''')
401 >                                  SQLSafeString(FilterText) + '%''')
402      else
403        Parser.Add2WhereClause('Upper(' + GetRelationNameQualifier + '"' +  ListField + '") Like Upper(''' +
404 <                                  SQLSafe(FilterText) + '%'')');
404 >                                  SQLSafeString(FilterText) + '%'')');
405  
406      if cbactSearchAscending in AutoCompleteText then
407      begin
# Line 561 | Line 566 | begin
566    FLastKeyValue := KeyValue;
567   end;
568  
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
569   procedure TIBLookupComboEditBox.UpdateShowing;
570   begin
571    inherited UpdateShowing;
# Line 587 | Line 581 | begin
581    FModified := false;
582   end;
583  
584 < {$if lcl_fullversion >= 2000000}
584 >
585 > {Workarounds due to bugs in various Lazarus 2.0 release candidates}
586 > {$if lcl_fullversion >= 2000002}
587   type
588  
589    { THackedCustomComboBox }
590  
591    THackedCustomComboBox = class(TCustomComboBox)
592    private
597    procedure CallUTF8KeyPress(var UTF8Key: TUTF8Char);
593      procedure CallChange;
594 +    procedure CallUTF8KeyPress(var UTF8Key: TUTF8Char);
595    end;
596  
597   { THackedCustomComboBox }
598  
603 procedure THackedCustomComboBox.CallUTF8KeyPress(var UTF8Key: TUTF8Char);
604 begin
605  inherited UTF8KeyPress(UTF8Key);
606 end;
607
599   procedure THackedCustomComboBox.CallChange;
600   begin
601    inherited Change;
602   end;
603  
604 < procedure TIBLookupComboEditBox.UTF8KeyPress(var UTF8Key: TUTF8Char);
604 > procedure THackedCustomComboBox.CallUTF8KeyPress(var UTF8Key: TUTF8Char);
605   begin
606 <  {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;
606 >  inherited UTF8KeyPress(UTF8Key);
607   end;
608  
609   procedure TIBLookupComboEditBox.Change;
610   begin
611 <  THackedCustomComboBox(self).CallChange;
611 >  if DataSource = nil then
612 >    THackedCustomComboBox(self).CallChange
613 >  else
614 >    inherited Change;
615   end;
616  
617   procedure TIBLookupComboEditBox.CloseUp;
618   begin
630  inherited CloseUp;
619    inherited DoEdit;
620 +  inherited CloseUp;
621 +  EditingDone;
622   end;
623  
624   procedure TIBLookupComboEditBox.Select;
625   begin
626    inherited Select;
627 <  inherited DoEdit;
627 >  if DataSource = nil then
628 >    inherited DoEdit;
629   end;
630  
631   function TIBLookupComboEditBox.DoEdit: boolean;
632   begin
633    {DoEdit will swallow characters if no editable Field. Hence, to enabled
634     writing we must avoid calling the inherited method.}
635 <  if ((DataSource = nil) or (Field = nil)) and not ReadOnly then
635 >  if DataSource = nil then
636      Result := true
637    else
638      Result := inherited DoEdit;
639   end;
640   {$ifend}
641  
642 + {$if lcl_fullversion = 2000002}
643 + procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
644 + begin
645 +  if DataSource = nil then
646 +    THackedCustomComboBox(self).UTF8KeyPress(UTF8Key)
647 +  else
648 +    inherited;
649 + end;
650 + {$ifend}
651 +
652 +
653   constructor TIBLookupComboEditBox.Create(TheComponent: TComponent);
654   begin
655    inherited Create(TheComponent);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines