Skip to main content

ChartMenus

Struct ChartMenus 

Source
pub struct ChartMenus {
    pub host_entries: Vec<HostMenuEntry>,
    /* private fields */
}
Expand description

The chart, series and drawing context menus of one Chart.

Keep one next to the chart and call show after each Chart::show: a right-click on the chart opens the menu for what it landed on, and the item the user picks comes back as a ChartContextAction. The menus follow the theme applied with apply_to_egui.

use egui_charts::ui::context_menu::{ChartContextAction, ChartMenus, HostMenuEntry};
use egui_charts::widget::RightClickTarget;
let mut menus = ChartMenus::default();
menus.host_entries.push(HostMenuEntry::new("ticket", "Send to ticket")
    .when(|click| matches!(click.target, RightClickTarget::Background { .. })));
// After chart.show(ui), handle ChartContextAction::Host { id, context } from menus.show.

Fields§

§host_entries: Vec<HostMenuEntry>

Host rows in display order. Empty by default.

Implementations§

Source§

impl ChartMenus

Source

pub fn series_click_price(&self) -> f64

The price of the series menu’s last right-click, which stays after a pick.

Source

pub fn set_control_visible(&mut self, control: Control, visible: bool)

Shows or hides named menu entries: Alerts, Trading, Settings, ObjectTree, Indicators, ResetView, CopyPrice, ExportData, TimeZone and Session. ContextMenus disables all menus, including drawings and axes. Controls belonging only to toolbars are ignored.

Source

pub fn set_order_entries(&mut self, quantity: f64, capabilities: Capabilities)

Sets the quantity of the chart menu’s order entries and the order types the account accepts, such as Trading::quantity and Trading::capabilities. By default the entries are for 1 unit and offer limit and stop orders.

Source

pub fn set_watchlists( &mut self, names: impl IntoIterator<Item = impl Into<String>>, )

Offers adding the chart’s symbol to these watchlists, such as the names of WatchlistPanel::lists, in a submenu. The choice returns as ContextMenuAction::AddToWatchlist with the list’s index. Without names the menu has no such entry.

Source

pub fn show( &mut self, ctx: &Context, chart: &mut Chart, ) -> Option<ChartContextAction>

Opens the menu for the chart’s last right-click, shows the open one and returns the chosen action. While a menu is open the chart draws no crosshair or tooltip under it.

Trait Implementations§

Source§

impl Default for ChartMenus

Source§

fn default() -> ChartMenus

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
§

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.