-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TBaseVirtualTree disable single letter incremental search #837
Comments
Sorry, but I don't think that the current incremental search behavior is so bad. Virtual TreeView already has so many options, that they are hard to maintain and hard to understand for new developers. This is why I am very carefully in adding new options. |
It's not bad at all. I really like how Virtual TreeView works. Blazing fast, versatile, it's an obvious choice for many tasks. First thing I've tried was subclassing TCustomVirtualStringTree, override HandleIncrementalSearch, but some properties and methods used in parent class are private, so I would end up with duplicating a lot of code that already exist in parent class. I am aware that Virtual TreeView has (too) many options that could be hard to find for new developers. Maybe we could instead add a property to TVirtualTreeColumn and TBaseVirtualTree, or at least event handler in TBaseVirtualTree.HandleIncrementalSearch in order to enable to switch SingleLetter on/off. That would not disturb option sets for TVirtualTreeColumn and TBaseVirtualTree. |
Just let us know what to method this applies and if we need to extract methods from existing. Making methods virtual is typically no problem.
That's true but you can't do that every week. :-) It would be good if this could be handled in the |
Current implementation is this (in TBaseVirtualTree.HandleIncrementalSearch) : SingleLetter := (Length(FSearchBuffer) = 1) and not PreviousSearch and (FSearchBuffer[1] = NewChar);
// However if the current hit (if there is one) would fit also with a repeated character then
// don't use single letter mode.
if SingleLetter and (DoIncrementalSearch(Run, FSearchBuffer + NewChar) = 0) then
SingleLetter := False;
SetupNavigation; we might try to change it to : var AllowSingleLetterIncSearch : boolean;
SingleLetter := (Length(FSearchBuffer) = 1) and not PreviousSearch and (FSearchBuffer[1] = NewChar);
// However if the current hit (if there is one) would fit also with a repeated character then
// don't use single letter mode.
AllowSingleLetterIncSearch := True;
if SingleLetter and (DoIncrementalSearch(Run, FSearchBuffer + NewChar, AllowSingleLetterIncSearch) = 0) then
SingleLetter := False;
SingleLetter := SingleLetter and AllowSingleLetterIncSearch;
SetupNavigation; but this would require to add parameter to DoIncrementalSearch method and OnIncrementalSearch event |
Changing events in Delphi is always a breaking change, that's the downside. Besides that I like this approach. |
How about adding dedicated event like : // However if the current hit (if there is one) would fit also with a repeated character then
// don't use single letter mode.
SingleLetter := DoAllowSingleLetterIncrementalSearch(Run);
if SingleLetter and (DoIncrementalSearch(Run, FSearchBuffer + NewChar) = 0) then
SingleLetter := False;
SetupNavigation; with TVTAllowSingleLetterIncrementalSearchEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode;
var Result: Boolean) of object; and function TBaseVirtualTree.DoAllowSingleLetterIncrementalSearch(Node: PVirtualNode): Boolean;
begin
Result := True;
if Assigned(FOnAllowSingleLetterIncrementalSearch) then
FOnAllowSingleLetterIncrementalSearch(Self, Node, Result);
end; |
Well, the same applies here like for the TreeOptions: You can't add an event for any edge case. I still like the additional parameter in the existing event more. |
I will accept a pull request for this for V8, which already includes a few breaking changes. |
Maybe the parameter could have a default value so it is optional and the breakage thus is minimized? |
Default parameters don't help for events if the old code doesn't expect this new parameter. It's a common problem in Delphi, too much to explain here. |
Steps to reproduce :
Suggested resolution:
That way we can disable single letter incremental search per column / per tree as needed.
The text was updated successfully, but these errors were encountered: