Skip to main content

SymbolSearchDialog

Struct SymbolSearchDialog 

Source
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

Source

pub fn new() -> Self

Creates a new symbol search dialog with default configuration

Source

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()
    });
Source

pub fn set_search_service(&mut self, service: Option<Arc<dyn SymbolSearch>>)

Connects host symbol search. Without a service, show searches its supplied list.

Source

pub fn set_storage(&mut self, storage: Arc<dyn Storage>)

Keeps recently selected instruments through the host’s storage service.

Source

pub fn set_exchange_filter(&mut self, exchange: Option<String>)

Restricts results to an exchange, or removes that filter, as the source menu does.

Source

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.

Source

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.

Source

pub fn record_symbol(&mut self, symbol: &Instrument)

Records an instrument opened outside this dialog in the recent list.

Source

pub fn set_recent_symbols(&mut self, symbols: Vec<String>)

Supply recent symbol names, newest first. Unknown names are ignored.

Source

pub fn open(&mut self)

Opens the symbol search dialog

Clears any previous search state and shows the dialog.

Source

pub fn open_with_query(&mut self, query: String)

Open symbol search with text supplied by the host’s keyboard dispatcher.

Source

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.

Source

pub fn close(&mut self)

Closes the symbol search dialog

Source

pub fn is_open(&self) -> bool

Returns whether the dialog is currently open

Source

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 context
  • all_symbols - List of all available symbols to search from
§Returns
  • Some(Instrument) - The symbol selected by the user
  • None - 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§

Source§

impl Default for SymbolSearchDialog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.