0

I have the following menu item

fn update(&mut self, ctx: &egui::Context, frame: &epi::Frame) {
    //let Self { label, value } = self; 

    // Examples of how to create different panels and windows.
    // Pick whichever suits you.
    // Tip: a good default choice is to just keep the `CentralPanel`.
    // For inspiration and more examples, go to https://emilk.github.io/egui

    egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
        // The top panel is often a good place for a menu bar:
        egui::menu::bar(ui, |ui| {
            ui.menu_button("File", |ui| {
                if ui.button("Quit").clicked() {
                    frame.quit();
                }
            });
            ui.menu_button("Items", |ui| {
                if ui.button("Exchanges").clicked() {
                    println!("Exchanges");
                    ui.close_menu();
                    exchange_trans(ctx);
                                        }
                if ui.button("Coins").clicked() {
                    println!("Coins");
                    ui.close_menu();
                }
                if ui.button("Transactions").clicked() {
                    println!("Transactions");
                    ui.close_menu();
                }
            });

I call '''

pub fn exchange_trans(ctx: &egui::Context) {
    egui::SidePanel::left("side_panel").show(ctx, |ui| {
        ui.heading("My egui Application");
    ui.horizontal(|ui| {
        ui.label("Your name: ");
        ui.group(|ui| {
            ui.label("Within a frame");
            ui.set_min_height(200.0);
        });
        
       // ui.text_edit_singleline(&mut name);
    });
}

''' The problem is that a black screen shows up when it is available to select a menu item. When I select the Exchange menu item the screen blinks and then black to black. I think the refresh rate is set to continuous and I need it set to reactive. How do I do it or am I on the wrong track.

Chandan
  • 11,465
  • 1
  • 6
  • 25
John
  • 1
  • 3

1 Answers1

0

You don't have to disable update. I would try to do as in the example https://github.com/emilk/eframe_template/blob/master/src/app.rs

 fn update(..) {
   ...
   if my_variable {
     egui::SidePanel::left("side_panel").show(ctx, |ui| {
        ui.heading("My egui Application");
        ....
    });  
   }
}

and from the menu changes my_variable to true of false - not executing the method exchange_trans(ctx); because it will be overwritten by the update

             ui.menu_button("Items", |ui| {
                if ui.button("Exchanges").clicked() {
                    println!("Exchanges");
                    ui.close_menu();
                    my_variable = !my_variable;
Grzesiek
  • 715
  • 5
  • 24