Settings - Add Searchbar - #1825
Merged
Merged
Conversation
PabstMirror
approved these changes
Jul 29, 2026
rautamiekka
suggested changes
Aug 5, 2026
| private _category = uiNamespace getVariable [QGVAR(addon), ""]; | ||
| private _source = uiNamespace getVariable [QGVAR(source), ""]; | ||
|
|
||
| if (_category isEqualTo "" || {_source isEqualTo ""}) exitWith {}; |
Contributor
There was a problem hiding this comment.
Suggested change
| if (_category isEqualTo "" || {_source isEqualTo ""}) exitWith {}; | |
| if (_category isEqualTo "" || _source isEqualTo "") exitWith {}; |
Not worth the lazy eval, isEqualTo is faster.
|
|
||
| if (!isNil "_members") then { | ||
| // hide sub-category headers that have no settings left | ||
| private _show = (_members findIf {ctrlShown _x}) != -1; |
Contributor
There was a problem hiding this comment.
Suggested change
| private _show = (_members findIf {ctrlShown _x}) != -1; | |
| private _show = (_members findIf {ctrlShown _x}) isNotEqualTo -1; |
| _handled = true; | ||
| }; | ||
| }; | ||
| // ----- swallow enter in the search bar, it would close the dialog |
Contributor
There was a problem hiding this comment.
Suggested change
| // ----- swallow enter in the search bar, it would close the dialog | |
| // ----- swallow Enter in the search bar, it would close the dialog |
| // ----- adding to the search can only ever remove results, so only search through those again | ||
| private _searchScope = createHashMap; | ||
|
|
||
| if (_lastSearchText isNotEqualTo "" && {(_searchText find _lastSearchText) == 0}) then { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (_lastSearchText isNotEqualTo "" && {(_searchText find _lastSearchText) == 0}) then { | |
| if (_lastSearchText isNotEqualTo "" && {(_searchText find _lastSearchText) isEqualTo 0}) then { |
I don't see why not use findIf instead of find, though.
| private _fields = [_displayName, _setting, _tooltip, _category, _subCategory]; | ||
|
|
||
| // list labels and their tooltips are searchable as well | ||
| if (toUpper _settingType == "LIST") then { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (toUpper _settingType == "LIST") then { | |
| if (toUpper _settingType isEqualTo "LIST") then { |
| }; | ||
|
|
||
| // ----- nothing matches at all, keep the category so it comes back when the search is cleared | ||
| if (_index == -1 && {lbSize _ctrlAddonList == 0}) exitWith { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (_index == -1 && {lbSize _ctrlAddonList == 0}) exitWith { | |
| if (_index isEqualTo -1 && {lbSize _ctrlAddonList isEqualTo 0}) exitWith { |
I wonder if, combined with isEqualTo, lbSize would be faster than lazy eval.
| }; | ||
|
|
||
| // ----- the category is gone, show the first one that's left instead | ||
| if (_index == -1) exitWith { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (_index == -1) exitWith { | |
| if (_index isEqualTo -1) exitWith { |
| onSetFocus = QUOTE((ctrlParent (_this select 0)) setVariable [ARR_2(QQGVAR(searchFocus),true)]); | ||
| onKillFocus = QUOTE((ctrlParent (_this select 0)) setVariable [ARR_2(QQGVAR(searchFocus),false)]); | ||
| // right click clears the search | ||
| onMouseButtonClick = QUOTE(if ((_this select 1) == 1) then {(_this select 0) ctrlSetText ''; [ctrlParent (_this select 0)] call FUNC(gui_search)}); |
Contributor
There was a problem hiding this comment.
Suggested change
| onMouseButtonClick = QUOTE(if ((_this select 1) == 1) then {(_this select 0) ctrlSetText ''; [ctrlParent (_this select 0)] call FUNC(gui_search)}); | |
| onMouseButtonClick = QUOTE(if ((_this select 1) isEqualTo 1) then {(_this select 0) ctrlSetText ''; [ctrlParent (_this select 0)] call FUNC(gui_search)}); |
I ain't sure, but it probly would be better if _this select 0 wasn't called twice like this. I'm even less sure what that array element even is, so what I'd call the variable is very difficult to say.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When merged this pull request will:
also does fuzzy matching: