pub fn update(
        &mut self,
        window: Option<WindowId>,
        data: &T,
        env: &Env,
    ) -> Option<PlatformMenu> {
        if let (Some(menu), Some(old_data)) = (self.menu.as_mut(), self.old_data.as_ref()) {
            let ret = match menu.update(old_data, data, env) {
                MenuUpdate::NeedsRebuild => {
                    if let Some(build) = &mut self.build {
                        self.menu = Some((build)(window, data, env));
                    } else {
                        tracing::warn!("tried to rebuild a context menu");
                    }
                    Some(self.refresh(data, env))
                }
                MenuUpdate::NeedsRefresh => Some(self.refresh(data, env)),
                MenuUpdate::UpToDate => None,
            };
            self.old_data = Some(data.clone());
            ret
        } else {
            tracing::error!("tried to update uninitialized menus");
            None
        }
    }
/// Update the menu based on a change to the data.
///
/// Returns a new `PlatformMenu` if the menu has changed; returns `None` if it hasn't.
Update the menu based on a change to the data.
Returns a new `PlatformMenu` if the menu has changed; returns `None` if it hasn't.
Update the menu based on a change to the data . Returns a new ` PlatformMenu ` if the menu has changed ; returns ` None ` if it hasn ' t .
pub fn update(
        &mut self,
        window: Option<WindowId>,
        data: &T,
        env: &Env,
    ) -> Option<PlatformMenu> {
        if let (Some(menu), Some(old_data)) = (self.menu.as_mut(), self.old_data.as_ref()) {
            let ret = match menu.update(old_data, data, env) {
                MenuUpdate::NeedsRebuild => {
                    if let Some(build) = &mut self.build {
                        self.menu = Some((build)(window, data, env));
                    } else {
                        tracing::warn!("tried to rebuild a context menu");
                    }
                    Some(self.refresh(data, env))
                }
                MenuUpdate::NeedsRefresh => Some(self.refresh(data, env)),
                MenuUpdate::UpToDate => None,
            };
            self.old_data = Some(data.clone());
            ret
        } else {
            tracing::error!("tried to update uninitialized menus");
            None
        }
    }
pub fn update ( & mut self , window : Option < WindowId > , data : & T , env : & Env , ) -> Option < PlatformMenu > { if let ( Some ( menu ) , Some ( old_data ) ) = ( self . menu . as_mut ( ) , self . old_data . as_ref ( ) ) { let ret = match menu . update ( old_data , data , env ) { MenuUpdate :: NeedsRebuild => { if let Some ( build ) = & mut self . build { self . menu = Some ( ( build ) ( window , data , env ) ) ; } else { tracing :: warn ! ( " " ) ; } Some ( self . refresh ( data , env ) ) } MenuUpdate :: NeedsRefresh => Some ( self . refresh ( data , env ) ) , MenuUpdate :: UpToDate => None , } ; self . old_data = Some ( data . clone ( ) ) ; ret } else { tracing :: error ! ( " " ) ; None } }
Update the menu based on a change to the data.
Update the menu based on a change to the data .
&mut self
window
Option<WindowId>
data
&T
env
&Env
&mut self
window
Option<WindowId>
data
&T
env
&Env