PrintPreviewDialog ToolStripButton's tooltip is last work item's after changing zoom's value
.NET version
.NET 9.0.100-preview.3.24128.12
Did it work in .NET Framework?
Not tested/verified
Did it work in any of the earlier releases of .NET Core or .NET 5+?
It doesn't repro on .NET 6.0, repro from .NET 7.0 to .NET 9.0.
Issue description
PrintPreviewDialog ToolStripButton's tooltip is last work item's after changing zoom's value
Steps to reproduce
- Create Winforms .NET Core project.
- Add button, PrintDocument and PrintPreviewDialog controls.
- Double click button and add below codes: "printPreviewDialog.Document = myDocument; printPreviewDialog.ShowDialog();"
- Run project.
- Click button to open PrintPreviewDialog.
- Tab through to Zoom and change zoom's value.
- Continue to tab through all ToolStripButton's and observe ToolStripButton's tooltip.
https://github.com/dotnet/winforms/assets/130345015/ea28374c-ba7d-4e22-8f50-371be223d5eb
Actual:
All ToolStripButton's 's tooltip is correct.
Expected:
PrintPreviewDialog ToolStripButton's tooltip is last work item's.
@LeafShi1 can your team take a look and see what might be happening here?
This issue no longer repro in .NET 9.0.100-preview.1.24101.2:
Related code was changed very recently, which may have solved the issue:
Closing the issue, as it no longer repro on latest version.
Verified this issue on .NET 9.0.100-Preview.3.24163.23, this issue still reproes. It only reproes when you tab through PrintPreviewDialog ToolStripButton.
https://github.com/dotnet/winforms/assets/130345015/d5d50d96-97b8-4e36-b25d-6b90182df83a
It seems that this problem is because after changing Zoom, the keyboardToolTip still stores the previous Selected tool "Print".
Set _currentTool = LastFocusedTool; can resolve this issue, but the tooltip will not be displayed in the correct position
https://github.com/dotnet/winforms/blob/fccada2ef35a4deb69e02f4ce558e68377f1fb35/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip/KeyboardToolTipStateMachine.cs#L184
Set a condition breakpoint (toolText == "Two pages (Ctrl+2)") in https://github.com/dotnet/winforms/blob/fccada2ef35a4deb69e02f4ce558e68377f1fb35/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripItem.cs#L2020 can watch the wrong value of the _currentTool
@ricardobossan Hope this information can provide some help
Verified it in the latest .Net 9.0 SDK build: 9.0.100-preview.4.24177.8, it was fixed: All ToolStripButton's 's tooltip is correct.
https://github.com/dotnet/winforms/assets/86937911/6c40163b-e4a6-434e-8e53-441ad2c3cf94