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

Non-modal settings window loses focus after accepting dialog #7419

Closed
n8bot opened this issue Dec 4, 2021 · 10 comments
Closed

Non-modal settings window loses focus after accepting dialog #7419

n8bot opened this issue Dec 4, 2021 · 10 comments

Comments

@n8bot
Copy link
Contributor

n8bot commented Dec 4, 2021

Version

2.4.0-beta3 stock prusaslicer build I promise I did not break it

Operating system type + version

Win 10 64

Behavior

When using non-modal settings, the focus is returned to the main window when a dialog is dismissed/accepted. E.g., when a profile itself is saved, the focus immediately returns to main window. When the ramming settings dialog is entered, there is a notification about the setting being for experts, when you click OK, the main window regains focus, so the ramming settings window is lost and seems like it is closed by error, when it's just under the window.

This seems related to the recent focus changes targeted to help linux, but I have not confirmed that is the case.

As a side note:

I noticed that on user profiles (not system profiles), there are two settings that always have the orange unlocked icon, even though they are at the system defaults:

image

@bubnikv
Copy link
Collaborator

bubnikv commented Dec 4, 2021 via email

@bubnikv bubnikv closed this as completed in bfce4f6 Dec 5, 2021
@bubnikv
Copy link
Collaborator

bubnikv commented Dec 5, 2021

hopefully fixed for good with bfce4f6

@n8bot
Copy link
Contributor Author

n8bot commented Dec 5, 2021

The originally described issue is fixed. However, when the "Supports work better if..." dialog comes up, while in a modal settings menu, the same problem occurs.

@bubnikv
Copy link
Collaborator

bubnikv commented Dec 5, 2021 via email

@n8bot
Copy link
Contributor Author

n8bot commented Dec 5, 2021

No, sorry, the focus is brought to the main window, when you click "no" or whatever.

The ramming settings dialog is fixed, and the save profile dialog is fixed... but when the "support work better if..." dialog comes up, the focus problem described in this issue is still there.

@n8bot
Copy link
Contributor Author

n8bot commented Dec 5, 2021

Just to correct myself slightly: with the "Support works better..." dialog, the non-modal settings loses focus IMMEDIATELY when that dialog pops up, and then the focus is returned to the main window, not the non-modal settings window.

To illicit this dialog message, Edit some user profile that is new, save it in a state where Detect bridging perimeters is disabled, and support generation is also disabled. Once it is saved in that state, try to enable support generation, and the "Support works better..." dialog should pop up. Since this happens only once per profile (thank you!) you have to set up the scenario correctly to ensure you see it. I'm guessing you know this, but just to refresh it in your mind because the app is complex so it might be nice to have the exact steps right here.

@n8bot
Copy link
Contributor Author

n8bot commented Dec 5, 2021

I suppose it is because this dialog is of type MessageDialog and not wxMessageDialog:

if (config->opt_bool("support_material")) {
// Ask only once.
if (!m_support_material_overhangs_queried) {
m_support_material_overhangs_queried = true;
if (!config->opt_bool("overhangs")/* != 1*/) {
wxString msg_text = _(L("Supports work better, if the following feature is enabled:\n"
"- Detect bridging perimeters"));
if (is_global_config)
msg_text += "\n\n" + _(L("Shall I adjust those settings for supports?"));
MessageDialog dialog(nullptr, msg_text, _L("Support Generator"), wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
if (!is_global_config || answer == wxID_YES) {
// Enable "detect bridging perimeters".
new_conf.set_key_value("overhangs", new ConfigOptionBool(true));
}
//else Do nothing, leave supports on and "detect bridging perimeters" off.
apply(config, &new_conf);
}
}
}

[Edit: can confirm, changing type to wxMessageDialog fixes the focus issue. However, the dialog is now not dark-themed.]

@n8bot
Copy link
Contributor Author

n8bot commented Dec 5, 2021

... and now I realize that the dialog pops up EVERY TIME you enable support generation, if detect bridging perimeters is disabled...

Please... can we just NOT with these dialogs? There MUST be some better way to communicate the intended use of settings... because these dialogs are nothing but problems. Do they benefit anybody?

[Edit: the reason the message appears every time you enable supports, is because of the else statement I left off:

}
else {
m_support_material_overhangs_queried = false;
}

If else statement is omitted, the dialog works correctly. It asks only once, and only under the conditions it states.

With the else statement, every time some other thing updates the config, the check is set back to false so it asks again.

@n8bot
Copy link
Contributor Author

n8bot commented Dec 5, 2021

The "Support works better, if..." dialog also enters an endless loop...

If you are in a scenario where the dialog has asked you once already if you want to detect bridges, and you select no... then you add a modifier to a model. Then, you attempt to add the setting Fuzzy Skin, it will bring up the endless loop dialog -- only OK button, which dismisses it then it pops back up.

image

Sorry this is no longer directly related to this issue, but it kinda seems easiest to keep it all here.

YuSanka added a commit that referenced this issue Dec 6, 2021
… dialog (MSW specific issue)

MessageDialog is used instead of wxMessageDialog on MSW for supporting of the Light/Dark color mode.
But a constructor of the MsgDialog replaces a parent which is equal to nullptr with the MainFrame .
That is why non-modal dialog with Preset Settings loses a focus after close of the MessageDialog.

"m_msg_dlg_parent" is added to ConfigManipulation class. ConfigManipulation's instance owed by Tab will use the Tab as a parent for MessageDialogs.
=> The MessageDialog with information about configuration incompatibility will always appear over related SettingsTab
and a non-modal dialog with Preset Settings will not lose the focus.
YuSanka added a commit that referenced this issue Dec 7, 2021
When part's configuration is updated =>
Don't call config_manipulation.update_print_fff_config() separately for applied object's config and then applied own config.
Configuration have to be applied from object config and its config. And than call config_manipulation.update_print_fff_config().

+ Redundant call of the update_config_values() is deleted from DeleteButton event. All checks are made during update_settings_list().
@n8bot
Copy link
Contributor Author

n8bot commented Dec 7, 2021

@bubnikv @YuSanka (sorry for ping, this issue is closed so I thought this might be necessary to draw attention)

We have another dialog that steals focus from non-modal settings, then returns it to the main frame:

When you click on the name of a setting, with a hyperlink:

image

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

No branches or pull requests

2 participants