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

[Bug]: KryptonMessageBoxDefaultButton.Button2 doesn't work #1837

Open
ICloneableX opened this issue Nov 5, 2024 · 1 comment
Open

[Bug]: KryptonMessageBoxDefaultButton.Button2 doesn't work #1837

ICloneableX opened this issue Nov 5, 2024 · 1 comment
Assignees
Labels
area:toolkit All issues related to the toolkit components. bug Something isn't working regression Something was working in a previous release, but isn't working now. under investigation This bug/issue is currently under investigation. version:85-lts All things to do with V85 LTS. version:95 All things to do with V95. version:100 All things to do with V100.

Comments

@ICloneableX
Copy link

ICloneableX commented Nov 5, 2024

Describe the bug
KryptonMessageBoxDefaultButton.Button2 or KryptonMessageBoxDefaultButton.Button3 doesn't work and button1 always gets the focus.

To Reproduce

KryptonMessageBox.Show("question?", "title", KryptonMessageBoxButtons.YesNo, 
                       KryptonMessageBoxIcon.Warning, KryptonMessageBoxDefaultButton.Button2);

Expected behavior
Button2 (the No button in this case) should have the focus. However, button1 (Yes) gets the focus instead.

Desktop (please complete the following information):

  • OS: Windows 10
  • Framework/.NET Version: .NET 8.0
  • Toolkit Version: 85.24.10.288
@ICloneableX ICloneableX added the bug Something isn't working label Nov 5, 2024
@giduac
Copy link

giduac commented Nov 6, 2024

Hi @ICloneableX,

Thanks for posting.

Possible solution (not tested yet) to set the focus at the end of the constructor
(AcceptButton as KryptonButton)?.Focus();

Krypton Components\Krypton.Toolkit\Controls Visuals\VisualMessageBoxForm.cs

internal VisualMessageBoxForm(IWin32Window? showOwner, string? text, string? caption,
							   KryptonMessageBoxButtons buttons,
							   KryptonMessageBoxIcon icon,
							   KryptonMessageBoxDefaultButton defaultButton,
							   HelpInfo? helpInfo, bool? showCtrlCopy,
							   bool? showHelpButton,
							   bool? showCloseButton)
{
	// Store incoming values
	_text = CommonHelper.NormalizeLineBreaks(text ?? string.Empty);
	_caption = caption;
	_buttons = buttons;
	_kryptonMessageBoxIcon = icon;
	_defaultButton = defaultButton;
	_helpInfo = helpInfo;
	_showOwner = showOwner;
	_showHelpButton = showHelpButton ?? (helpInfo != null);
	_krtbNativeWindow = new();

	// Create the form contents
	InitializeComponent();

	// Hookup the native window on the KRTB, only after IntializeComponent().
	_krtbNativeWindow.AssignHandle(krtbMessageText.RichTextBox.Handle);

	// Default Cursor for the KRTB when the cursors hovers over it
	krtbMessageText.RichTextBox.Cursor = Cursors.Arrow;

	// #1692 text font colour for input controls does not work correct on KMBees when using dark themes.
	// Set the text colour to the one a control uses.
	krtbMessageText.StateCommon.Content.Color1 = GlobalStaticValues.KryptonMessageBoxRichTextBoxTextColor;

	// Update contents to match requirements
	UpdateText();
	UpdateIcon();
	UpdateButtons();
	UpdateDefault();
	UpdateHelp();
	UpdateTextExtra(showCtrlCopy);
	// Finally calculate and set form sizing
	UpdateSizing(showOwner);

	ShowCloseButton(showCloseButton);

	(AcceptButton as KryptonButton)?.Focus();
}

@giduac giduac added version:85-lts All things to do with V85 LTS. version:100 All things to do with V100. version:95 All things to do with V95. labels Nov 6, 2024
@giduac giduac added this to the Version 85 (LTS) milestone Nov 6, 2024
@Smurf-IV Smurf-IV added regression Something was working in a previous release, but isn't working now. area:toolkit All issues related to the toolkit components. labels Nov 6, 2024
@PWagner1 PWagner1 self-assigned this Nov 6, 2024
@PWagner1 PWagner1 added the under investigation This bug/issue is currently under investigation. label Nov 6, 2024
@PWagner1 PWagner1 changed the title [Bug]: KryptonMessageBoxDefaultButton.Button2 doesn't work [Bug]: KryptonMessageBoxDefaultButton.Button2 doesn't work Nov 6, 2024
@PWagner1 PWagner1 removed their assignment Nov 6, 2024
@PWagner1 PWagner1 removed the under investigation This bug/issue is currently under investigation. label Nov 6, 2024
PWagner1 added a commit that referenced this issue Nov 7, 2024
@PWagner1 PWagner1 self-assigned this Nov 7, 2024
@PWagner1 PWagner1 added the under investigation This bug/issue is currently under investigation. label Nov 7, 2024
PWagner1 added a commit that referenced this issue Nov 7, 2024
PWagner1 added a commit that referenced this issue Nov 8, 2024
Smurf-IV added a commit that referenced this issue Nov 9, 2024
…xdefaultbuttonbutton2-doesnt-work-v85

* Resolved #1837 - V85
Smurf-IV added a commit that referenced this issue Nov 9, 2024
…xdefaultbuttonbutton2-doesnt-work

* Resolve #1837 - V100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:toolkit All issues related to the toolkit components. bug Something isn't working regression Something was working in a previous release, but isn't working now. under investigation This bug/issue is currently under investigation. version:85-lts All things to do with V85 LTS. version:95 All things to do with V95. version:100 All things to do with V100.
Projects
None yet
Development

No branches or pull requests

4 participants