Small tweaks to documentation and demo

This commit is contained in:
Emil Ernerfeldt
2021-12-29 10:49:22 +01:00
parent d0a47bf8e8
commit 84399cde83
4 changed files with 13 additions and 7 deletions
+4 -3
View File
@@ -437,13 +437,12 @@ impl Response {
/// Move the scroll to this UI with the specified alignment.
///
/// ```
/// # use egui::Align;
/// # egui::__run_test_ui(|ui| {
/// egui::ScrollArea::vertical().show(ui, |ui| {
/// for i in 0..1000 {
/// let response = ui.button(format!("Button {}", i));
/// let response = ui.button("Scroll to me");
/// if response.clicked() {
/// response.scroll_to_me(Align::Center);
/// response.scroll_to_me(egui::Align::Center);
/// }
/// }
/// });
@@ -490,6 +489,8 @@ impl Response {
/// });
/// # });
/// ```
///
/// See also: [`Ui::menu_button`] and [`Ui::close_menu`].
pub fn context_menu(self, add_contents: impl FnOnce(&mut Ui)) -> Self {
self.ctx
.context_menu_system()
+8 -2
View File
@@ -1763,7 +1763,9 @@ impl Ui {
result
}
/// Close menu (with submenus), if any.
/// Close the menu we are in (including submenus), if any.
///
/// See also: [`Self::menu_button`] and [`Response::context_menu`].
pub fn close_menu(&mut self) {
if let Some(menu_state) = &mut self.menu_state {
menu_state.write().close();
@@ -1780,7 +1782,9 @@ impl Ui {
}
#[inline]
/// Create a menu button. Creates a button for a sub-menu when the `Ui` is inside a menu.
/// Create a menu button that when clicked will show the given menu.
///
/// If called from within a menu this will instead create a button for a sub-menu.
///
/// ```
/// # egui::__run_test_ui(|ui| {
@@ -1793,6 +1797,8 @@ impl Ui {
/// });
/// # });
/// ```
///
/// See also: [`Self::close_menu`] and [`Response::context_menu`].
pub fn menu_button<R>(
&mut self,
title: impl Into<WidgetText>,