Skip to content

Commit

Permalink
Apply suggestions from emil
Browse files Browse the repository at this point in the history
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
  • Loading branch information
lucasmerlin and emilk authored Sep 10, 2024
1 parent 22466f9 commit 6165cec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ impl Ui {
///
/// On the first frame, when the [`Ui`] is created, this will return a [`Response`] with a
/// [`Rect`] of [`Rect::NOTHING`].
pub fn read_response(&self) -> Response {
pub fn response(&self) -> Response {
// This is the inverse of Context::read_response. We prefer a response
// based on last frame's widget rect since the one from this frame is Rect::NOTHING until
// Ui::interact_bg is called or the Ui is dropped.
Expand All @@ -1027,7 +1027,7 @@ impl Ui {
/// The rectangle of the [`Response`] (and interactive area) will be [`Self::min_rect`].
/// You can customize the [`Sense`] via [`UiBuilder::sense`].
// This is marked as deprecated for public use but still makes sense to use internally.
#[deprecated = "Use Ui::read_response instead"]
#[deprecated = "Use Uibuilder::sense with Ui::response instead"]
pub fn interact_bg(&self) -> Response {
// We remove the id from used_ids to prevent a duplicate id warning from showing
// when the ui was created with `UiBuilder::sense`.
Expand Down Expand Up @@ -2886,6 +2886,7 @@ impl Drop for Ui {
fn drop(&mut self) {
if self.should_interact_bg_on_drop {
#[allow(deprecated)]
// Register our final `min_rect`
self.interact_bg();
}
register_rect(self, self.min_rect());
Expand Down
4 changes: 3 additions & 1 deletion crates/egui/src/ui_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ impl UiBuilder {
self
}

/// Sense of the Ui. Should be the same as the one passed to [`Ui::interact_bg`]
/// Set if you want sense clicks and/or drags.
///
/// The response can be read with [`Ui::response`].
#[inline]
pub fn sense(mut self, sense: Sense) -> Self {
self.sense = Some(sense);
Expand Down

0 comments on commit 6165cec

Please sign in to comment.