ImSearch is an immediate mode extension for Dear ImGui, allowing you to create searchbars for ImGui's buttons, trees, selectable, and every other widget you can imagine.
Just like ImGui, ImSearch's API does not burden the end user with state management, use STL containers or include any C++ headers, and has no public dependencies except for ImGui itself. This extension is compatible with C++11 and above.
![]() Combos, previews and autocomplete |
![]() Hierarchies |
---|---|
![]() Collapsing headers and nested search bars |
![]() Custom search bars |
Real world examples from Coral Engine |
||
---|---|---|
![]() World outliner, details panel, and asset selection |
![]() Content browser |
![]() Finding functions and types for easier scripting |
You'll find that the API still feels very familiar to ImGui, albeit slightly different from what you might expect from an ImGui extension; because this extension also takes control over the order to display items in, the library uses callbacks for submitting your widgets. First, start a new search context by calling ImSearch::BeginSearch
. Next, submit as many items as you want with the Push/PopSearchable functions, to which you provide callbacks to display your ImGui widget (e.g. Selectable
, Button
, TreeNode
, etc). Finally, wrap things up with a call to ImSearch::EndSearch()
. That's it!
static const char* selectedString = sImguiExtensions[0];
if (ImGui::BeginCombo("##Extensions", selectedString))
{
if (ImSearch::BeginSearch())
{
ImSearch::SearchBar();
for (const char* extension : sImguiExtensions)
{
ImSearch::SearchableItem(extension,
[&](const char* name)
{
const bool isSelected = name == selectedString;
if (ImGui::Selectable(name, isSelected))
{
selectedString = name;
}
});
}
ImSearch::EndSearch();
}
ImGui::EndCombo();
}
More examples of ImSearch's features and usages can be found in imsearch_demo.cpp
. Add this file to your sources and call ImSearch::ShowDemoWindow()
somewhere in your update loop. You are encouraged to use this file as a reference whenever you need it. The demo is always updated to show new features as they are added, so check back with each release!
- Set up an ImGui environment if you don't already have one.
- Add
imsearch.h
,imsearch_internal.h
,imsearch.cpp
, and optionallyimsearch_demo.cpp
to your sources. - Create and destroy an
ImSearchContext
wherever you do so for yourImGuiContext
:
ImGui::CreateContext();
ImSearch::CreateContext();
...
ImSearch::DestroyContext();
ImGui::DestroyContext();
You should be good to go!