egui icon indicating copy to clipboard operation
egui copied to clipboard

Allow a menu button's frame to be disabled

Open yusdacra opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Not being able to turn the frame off in a menu button.

Describe the solution you'd like

I would like to be able to turn the frame off, like i can with a normal button.

Describe alternatives you've considered

None.

Additional context

None.

yusdacra avatar Dec 23 '21 22:12 yusdacra

As a workaround, i managed to achieve this with:

			let response = ui.text_button(&title);
            let popup_id = ui.make_persistent_id("profile_menu");
            if response.clicked() {
                ui.memory().toggle_popup(popup_id);
            }
            egui::popup_below_widget(ui, popup_id, &response, |ui| { ... });

I can't seem to be able to use SubMenuButton however, so as a fallback i used normal buttons without frames.

yusdacra avatar Dec 23 '21 23:12 yusdacra

Could you maybe elaborate on which frame you mean? If I understand correctly you want to be able to customize the button opening the menu? This could probably be done by changing this function https://github.com/emilk/egui/blob/2d2022fb7290bf4fcca373ad3a0dc98b680a9203/egui/src/menu.rs#L162-L185 to work with a given button instead of creating it itself. It could basically work with other elements as well. Feel free to implement this, I can't say I have time to work intensively on this project at the moment..

Edit: actually I realize the function wants to modify the button in some ways if the menu is open. So there would probably be a trait needed to define how to do this for each type of element. MenuOpener or something like that with a function on_open(&mut self).

mankinskin avatar Apr 16 '22 23:04 mankinskin