pub struct SymbolSearchDialog { /* private fields */ }Expand description
Instrument search dialog with keyboard navigation
A modal dialog for searching and selecting symbols. Features:
- Real-time filtering as you type
- Keyboard navigation (Up/Down to move, Enter to select, Esc to close)
- Case-insensitive search
- Searches both symbol names and descriptions
§Example
use egui_charts::model::Instrument;
use egui_charts::ui::top_toolbar::{SymbolSearchConfig, SymbolSearchDialog};
let mut dialog = SymbolSearchDialog::new()
.with_config(SymbolSearchConfig {
max_results: 20,
..Default::default()
});
// Open the dialog (e.g., on Ctrl+K)
dialog.open();
// In your egui update loop
let symbols = vec![Instrument::new("BTCUSDT").with_description("Bitcoin")];
if let Some(symbol) = dialog.show(ctx, &symbols) {
// User selected a symbol
println!("Switching to: {}", symbol.symbol);
}Implementations§
Source§impl SymbolSearchDialog
impl SymbolSearchDialog
Sourcepub fn with_config(self, config: SymbolSearchConfig) -> Self
pub fn with_config(self, config: SymbolSearchConfig) -> Self
Sets a custom configuration for the dialog
§Example
use egui_charts::ui::top_toolbar::{SymbolSearchConfig, SymbolSearchDialog};
let dialog = SymbolSearchDialog::new()
.with_config(SymbolSearchConfig {
max_results: 50,
min_search_len: 2,
..Default::default()
});Sourcepub fn set_search_service(&mut self, service: Option<Arc<dyn SymbolSearch>>)
pub fn set_search_service(&mut self, service: Option<Arc<dyn SymbolSearch>>)
Connects host symbol search. Without a service, show searches its supplied list.
Sourcepub fn set_storage(&mut self, storage: Arc<dyn Storage>)
pub fn set_storage(&mut self, storage: Arc<dyn Storage>)
Keeps recently selected instruments through the host’s storage service.
Sourcepub fn set_exchange_filter(&mut self, exchange: Option<String>)
pub fn set_exchange_filter(&mut self, exchange: Option<String>)
Restricts results to an exchange, or removes that filter, as the source menu does.
Sourcepub fn set_sources(&mut self, sources: Vec<String>)
pub fn set_sources(&mut self, sources: Vec<String>)
Offers these exchanges in the source menu, whose choice reaches the service as
SymbolQuery::exchange. Without a service the
menu offers the exchanges of the supplied symbols.
Sourcepub fn set_feed_capabilities(&mut self, capabilities: &FeedCapabilities)
pub fn set_feed_capabilities(&mut self, capabilities: &FeedCapabilities)
Takes the exchanges and symbol classes the feed serves, known before any symbol resolves:
pass Chart::feed_capabilities. Reported
exchanges are the source menu’s choices, replacing those of the supplied symbols and
set_sources; an empty list offers none. Reported classes are the
category tabs. A list the feed does not report leaves the choices as they were.
Sourcepub fn record_symbol(&mut self, symbol: &Instrument)
pub fn record_symbol(&mut self, symbol: &Instrument)
Records an instrument opened outside this dialog in the recent list.
Sourcepub fn set_recent_symbols(&mut self, symbols: Vec<String>)
pub fn set_recent_symbols(&mut self, symbols: Vec<String>)
Supply recent symbol names, newest first. Unknown names are ignored.
Sourcepub fn open(&mut self)
pub fn open(&mut self)
Opens the symbol search dialog
Clears any previous search state and shows the dialog.
Sourcepub fn open_with_query(&mut self, query: String)
pub fn open_with_query(&mut self, query: String)
Open symbol search with text supplied by the host’s keyboard dispatcher.
Sourcepub fn open_with_selected_query(&mut self, query: String)
pub fn open_with_selected_query(&mut self, query: String)
Opens symbol search with the supplied text selected on its first focused frame, so typing replaces it. Hosts pass the current symbol when the user opens search from a toolbar or an action.
Sourcepub fn show(
&mut self,
ctx: &Context,
all_symbols: &[Instrument],
) -> Option<Instrument>
pub fn show( &mut self, ctx: &Context, all_symbols: &[Instrument], ) -> Option<Instrument>
Shows the symbol search dialog and returns the selected symbol
Displays a modal search dialog with real-time filtering and keyboard navigation.
§Arguments
ctx- The egui contextall_symbols- List of all available symbols to search from
§Returns
Some(Instrument)- The symbol selected by the userNone- Dialog closed without selection or still searching
§Keyboard Shortcuts
- Up/Down: Navigate results
- Enter: Select highlighted symbol
- Esc: Close dialog
§Example
let symbols = vec![
Instrument::new("BTCUSDT").with_description("Bitcoin / Tether"),
Instrument::new("ETHUSDT").with_description("Ethereum / Tether"),
];
if let Some(symbol) = dialog.show(ctx, &symbols) {
println!("User selected: {}", symbol.symbol);
}Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SymbolSearchDialog
impl !UnwindSafe for SymbolSearchDialog
impl Freeze for SymbolSearchDialog
impl Send for SymbolSearchDialog
impl Sync for SymbolSearchDialog
impl Unpin for SymbolSearchDialog
impl UnsafeUnpin for SymbolSearchDialog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more