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
impl ChartMenus
Sourcepub fn series_click_price(&self) -> f64
pub fn series_click_price(&self) -> f64
The price of the series menu’s last right-click, which stays after a pick.
Sourcepub fn set_control_visible(&mut self, control: Control, visible: bool)
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.
Sourcepub fn set_order_entries(&mut self, quantity: f64, capabilities: Capabilities)
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.
Sourcepub fn set_watchlists(
&mut self,
names: impl IntoIterator<Item = impl Into<String>>,
)
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.
Sourcepub fn show(
&mut self,
ctx: &Context,
chart: &mut Chart,
) -> Option<ChartContextAction>
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
impl Default for ChartMenus
Source§fn default() -> ChartMenus
fn default() -> ChartMenus
Auto Trait Implementations§
impl !RefUnwindSafe for ChartMenus
impl !Send for ChartMenus
impl !Sync for ChartMenus
impl !UnwindSafe for ChartMenus
impl Freeze for ChartMenus
impl Unpin for ChartMenus
impl UnsafeUnpin for ChartMenus
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