feat(header_bar): Show window menu on right click

With this, apps like cosmic-term require no changes to show the
compositor window menu when the header is right clicked.
This commit is contained in:
Ian Douglas Scott 2024-02-13 08:10:04 -08:00 committed by GitHub
parent 6adc037f40
commit cc8033d74b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View file

@ -16,6 +16,7 @@ pub fn header_bar<'a, Message>() -> HeaderBar<'a, Message> {
on_drag: None,
on_maximize: None,
on_minimize: None,
on_right_click: None,
start: Vec::new(),
center: Vec::new(),
end: Vec::new(),
@ -45,6 +46,10 @@ pub struct HeaderBar<'a, Message> {
#[setters(strip_option)]
on_minimize: Option<Message>,
/// A message emitted when the header is right clicked.
#[setters(strip_option)]
on_right_click: Option<Message>,
/// The window id for the headerbar.
#[setters(strip_option)]
window_id: Option<iced::window::Id>,
@ -337,6 +342,10 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
widget = widget.on_release(message);
}
if let Some(message) = self.on_right_click.clone() {
widget = widget.on_right_press(message);
}
widget.into()
}