pub trait ContextMenu: Debug {
// Required methods
fn open(&mut self, ctx: &ClickContext) -> bool;
fn close(&mut self);
fn is_open(&self) -> bool;
fn draw(&self, cmd_buf: &mut Vec<DrawCommand>, width: f32, height: f32);
fn pointer_event(
&mut self,
width: f32,
height: f32,
event: PointerEvent,
) -> MenuEventResult;
fn needs_repaint(&self) -> bool;
}Expand description
Required Methods§
Sourcefn open(&mut self, ctx: &ClickContext) -> bool
fn open(&mut self, ctx: &ClickContext) -> bool
Requests the menu at the given click position.
Returns true when the menu opened (and consumed the click);
implementations may return false to decline (e.g. no items apply).
Sourcefn draw(&self, cmd_buf: &mut Vec<DrawCommand>, width: f32, height: f32)
fn draw(&self, cmd_buf: &mut Vec<DrawCommand>, width: f32, height: f32)
Draws the open menu into cmd_buf in window coordinates.
Called every frame after the chrome so the menu paints on top of everything else. Implementations should emit nothing while closed.
Sourcefn pointer_event(
&mut self,
width: f32,
height: f32,
event: PointerEvent,
) -> MenuEventResult
fn pointer_event( &mut self, width: f32, height: f32, event: PointerEvent, ) -> MenuEventResult
Dispatches a pointer event to the open menu.
Only called while the menu is open. Returning
consumed keeps the event away from the
chrome and the page.
Sourcefn needs_repaint(&self) -> bool
fn needs_repaint(&self) -> bool
Whether the menu changed its visual state since the last check.
Consumes the flag, like crate::engine::ui::custom_node::CustomNode::needs_repaint.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".