Subject | Re: IncSearch does not work in TIB_Grid |
---|---|
Author | |
Post date | 2017-09-04T09:17:34Z |
Just found the source of the issue.
In the unit IB_Grid there is the method TIB_CustomGrid.DoIncSearchKeyPress.
In IBOv5.9 a part of that method is commented out and that was not commented out in v4.8.
When I uncommend it, incsearch works again.
Problem is, that I had to comment out the lines with FIncSearchLevel, as that does not exist any more.
I would like to know, why this part was commented out and if there are any issues when uncommenting it.
Jason, could you please take a look at it? I attach the source below, showing how it was in 4.8 and how it is in 5.9 before and after my correction.
Regards
Helmut
Here ist the method like it is in v4.8:
procedure TIB_CustomGrid.DoIncSearchKeyPress( var Key: char );varMatch: boolean;beginMatch := false;if ( DataLink.Dataset is TIB_BDataset ) andAssigned( DataLink.Dataset.OrderingField ) thenbeginwith DataLink.Dataset as TIB_BDataset dobeginif FGridFields.IndexOf( OrderingField ) >= 0 thenSelf.Col := GridCol[ FGridFields.IndexOf( OrderingField ) ];case Key of#08: if Length(FIncSearchText) > 0 thenSystem.Delete(FIncSearchText, Length(FIncSearchText), 1);#32..#255: if OrderingField.IsValidChar( Key ) thenFIncSearchText := FIncSearchText + Key;end;if Key = #27 thenbeginif FIncSearchText <> EmptyStr thenbeginMatch := IncSearchKey( Key, SearchKeyByKey, AllowTimeout,SeekNearest );FIncSearchText := IncSearchKeyString;//Key := #0;end;FIncSearchState := false;endelseif Prepared and(( Key in [ #08, #13 ] ) orOrderingField.IsValidChar( Key )) thenbeginif SearchKeyByKey and( OrderingField.IsText or( OrderingField.IsNumeric and( OrderingRefinePos > 0 ))) thenbeginInc( FIncSearchLevel );tryMatch := IncSearchKey( Key,SearchKeyByKey,AllowTimeout,SeekNearest );finallyDec( FIncSearchLevel );end;FIncSearchText := IncSearchKeyString;if Key = #13 thenFIncSearchState := false;//Key := #0;endelseif Key = #13 thenbeginInc( FIncSearchLevel );tryMatch := IncSearchString( FIncSearchText, 1, SeekNearest );finallyDec( FIncSearchLevel );end;//Key := #0;FIncSearchState := false;end;endelsebeginMessageBeep( 0 );//Key := #0;end;end;endelseMessageBeep( 0 );Key := #0;if FIncSearchText = '' thenMatch := false;if Assigned( FOnIncSearch ) thenFOnIncSearch( Self, FIncSearchText, Match );if not FIncSearchState thenFIncSearchText := EmptyStr;end;Here ist the method like it is in v5.9 (incsearch does not work):procedure TIB_CustomGrid.DoIncSearchKeyPress( var Key: char );varMatch: boolean;beginMatch := false;if ( DataLink.Dataset is TIB_BDataset ) andAssigned( DataLink.Dataset.OrderingField1 ) thenbeginwith DataLink.Dataset as TIB_BDataset dobeginif FGridFields.IndexOf( OrderingField1 ) >= 0 thenSelf.Col := GridCol[ FGridFields.IndexOf( OrderingField1 ) ];case Key of#08: if iboLength(FIncSearchText) > 0 theniboDelete(FIncSearchText, iboLength(FIncSearchText), 1);#32..#255: if OrderingField1.IsValidChar( Key ) thenFIncSearchText := FIncSearchText + Key;end;if Key = #27 thenbeginif FIncSearchText <> EmptyStr thenbeginMatch := IncSearchKey( Key, SearchKeyByKey, AllowTimeout,SeekNearest );FIncSearchText := IncSearchKeyString;//Key := #0;end;FIncSearchState := false;endelseif Prepared and((( Key = #08 ) or ( Key = #13 )) orOrderingField1.IsValidChar( Key )) thenbegin{!!!!if SearchKeyByKey and( OrderingField.IsText or( OrderingField.IsNumeric and( OrderingRefinePos > 0 ))) thenbeginInc( FIncSearchLevel );tryMatch := IncSearchKey( Key,SearchKeyByKey,AllowTimeout,SeekNearest );finallyDec( FIncSearchLevel );end;FIncSearchText := IncSearchKeyString;if Key = #13 thenFIncSearchState := false;//Key := #0;endelseif Key = #13 thenbeginInc( FIncSearchLevel );tryMatch := IncSearchString( FIncSearchText, 1, SeekNearest );finallyDec( FIncSearchLevel );end;//Key := #0;FIncSearchState := false;end;}endelsebeginMessageBeep( 0 );//Key := #0;end;end;endelseMessageBeep( 0 );Key := #0;if FIncSearchText = '' thenMatch := false;if Assigned( FOnIncSearch ) thenFOnIncSearch( Self, FIncSearchText, Match );if not FIncSearchState thenFIncSearchText := EmptyStr;end;And here ist the method like it is in v5.9 after my correction (incsearch does work):procedure TIB_CustomGrid.DoIncSearchKeyPress( var Key: char );varMatch: boolean;beginMatch := false;if ( DataLink.Dataset is TIB_BDataset ) andAssigned( DataLink.Dataset.OrderingField1 ) thenbeginwith DataLink.Dataset as TIB_BDataset dobeginif FGridFields.IndexOf( OrderingField1 ) >= 0 thenSelf.Col := GridCol[ FGridFields.IndexOf( OrderingField1 ) ];case Key of#08: if iboLength(FIncSearchText) > 0 theniboDelete(FIncSearchText, iboLength(FIncSearchText), 1);#32..#255: if OrderingField1.IsValidChar( Key ) thenFIncSearchText := FIncSearchText + Key;end;if Key = #27 thenbeginif FIncSearchText <> EmptyStr thenbeginMatch := IncSearchKey( Key, SearchKeyByKey, AllowTimeout,SeekNearest );FIncSearchText := IncSearchKeyString;//Key := #0;end;FIncSearchState := false;endelseif Prepared and((( Key = #08 ) or ( Key = #13 )) orOrderingField1.IsValidChar( Key )) thenbegin//{!!!!if SearchKeyByKey and( OrderingField.IsText or( OrderingField.IsNumeric and( OrderingRefinePos > 0 ))) thenbegin// Inc( FIncSearchLevel );tryMatch := IncSearchKey( Key,SearchKeyByKey,AllowTimeout,SeekNearest );finally// Dec( FIncSearchLevel );end;FIncSearchText := IncSearchKeyString;if Key = #13 thenFIncSearchState := false;//Key := #0;endelseif Key = #13 thenbegin// Inc( FIncSearchLevel );tryMatch := IncSearchString( FIncSearchText, 1, SeekNearest );finally// Dec( FIncSearchLevel );end;//Key := #0;FIncSearchState := false;end;//}endelsebeginMessageBeep( 0 );//Key := #0;end;end;endelseMessageBeep( 0 );Key := #0;if FIncSearchText = '' thenMatch := false;if Assigned( FOnIncSearch ) thenFOnIncSearch( Self, FIncSearchText, Match );if not FIncSearchState thenFIncSearchText := EmptyStr;end;