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

Add nsmenu title #1846

Merged
merged 8 commits into from
Jul 27, 2021
Merged

Add nsmenu title #1846

merged 8 commits into from
Jul 27, 2021

Conversation

terhechte
Copy link
Contributor

This is an initial fix for #1835.

It uses ::alloc().initWithTitle(...) to initialize NSMenu items with a correct title.
However, it is not clear to me yet what the behaviour would be for the Menu that is exposed from the druid crate.
Right now I'm calling Menu("") but I suppose that's wrong. My guess would be that the public druid API would also expose a title property? But then it would affect all platforms. Open to suggestions here :)

@cmyr
Copy link
Member

cmyr commented Jul 2, 2021

I think that initing with an empty string and then modifying it afterwards to the correct title should be okay?

@terhechte
Copy link
Contributor Author

Updated it accordingly to use an empty string and added set_title which only works on macOS and is a NOP on the other platforms

@@ -123,7 +123,8 @@ impl WinHandler for HelloState {

fn main() {
tracing_subscriber::fmt().init();
let mut file_menu = Menu::new("File Menu");
let mut file_menu = Menu::new();
file_menu.set_title("File Menu");
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just "File"?

@cmyr
Copy link
Member

cmyr commented Jul 5, 2021

Okay so I'm looking at this again, and I want to double-check my understanding:

  • druid-shell's Menu::new method is only called for root menus; that means the root application menu, as well as root popup menus.
  • all other items (such as the file menu) are created with the add_item and add_dropdown, which do correctly set titles

And in both the case of. the root menu and of a context menu, the title is (I believe) unused?

Ultimately I'm wondering if we need to bother with the whole set_title addition. My main concern with #1835 isn't with the title not being set, it's with a missing init call that may be performing other important work. If we can just init with an empty string and leave it at that, I'd be happy for the simplification..

@terhechte
Copy link
Contributor Author

@cmyr I agree. I've removed the set_title implementations. Just using an empty string should be enough.

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Thanks!

@cmyr cmyr mentioned this pull request Jul 26, 2021
@cmyr cmyr merged commit 25837a3 into linebender:master Jul 27, 2021
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.

3 participants