Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context Menu: Return owned Response from Response::context_menu #857

Merged
merged 1 commit into from
Nov 1, 2021

Conversation

mankinskin
Copy link
Contributor

Just a minor inconvenience I noticed, response.context_menu() returns a &Response. This can lead to annoying reference type errors because you may not be able to just move out of the reference.

I think I did this in the first place to avoid having to write let response = response.context_menu(); but I don't think this is a concern actually.

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@emilk emilk merged commit b9368ab into emilk:master Nov 1, 2021
emilk pushed a commit that referenced this pull request Jan 29, 2024
… if open (#3904)

Hi everyone! It's a great pleasure to work with such a library. It feels
like a breath of fresh air!

**Problem:**

The current implementation of `context_menu` consumes `self` and returns
it. However, the underlying `menu::context_menu` requires only a
reference to `self`, so it is safe to change the `context_menu`
signature.

**Fix:**

1. Change signature to take a ref to `self`. 
2. Return the `Option<InnerResponse<()>>` from the underlying method
call

**Pros:**

1. No `let response =  response.context_menu(|| {...})` pattern
2. Better consistency with other `show`-like methods, as it is in the
`Window::show`
3. Less ownership gymnastics

**Cons:**
1. Breaking change
2. Smth else what I don't see ?

**Additional info:**
- This method is also addressed in [this
PR](#857).
- `check.sh` fails only on `cargo check --quiet -p eframe
--no-default-features --features wgpu` with `"The platform you're
compiling for is not supported by winit"` error, should it be launched
at all ?
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 2024
… if open (emilk#3904)

Hi everyone! It's a great pleasure to work with such a library. It feels
like a breath of fresh air!

**Problem:**

The current implementation of `context_menu` consumes `self` and returns
it. However, the underlying `menu::context_menu` requires only a
reference to `self`, so it is safe to change the `context_menu`
signature.

**Fix:**

1. Change signature to take a ref to `self`. 
2. Return the `Option<InnerResponse<()>>` from the underlying method
call

**Pros:**

1. No `let response =  response.context_menu(|| {...})` pattern
2. Better consistency with other `show`-like methods, as it is in the
`Window::show`
3. Less ownership gymnastics

**Cons:**
1. Breaking change
2. Smth else what I don't see ?

**Additional info:**
- This method is also addressed in [this
PR](emilk#857).
- `check.sh` fails only on `cargo check --quiet -p eframe
--no-default-features --features wgpu` with `"The platform you're
compiling for is not supported by winit"` error, should it be launched
at all ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants