winforms icon indicating copy to clipboard operation
winforms copied to clipboard

PrintPreviewDialog ToolStripButton's tooltip is last work item's after changing zoom's value

Open Eudora-Li01 opened this issue 1 year ago • 4 comments

.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

  1. Create Winforms .NET Core project.
  2. Add button, PrintDocument and PrintPreviewDialog controls.
  3. Double click button and add below codes: "printPreviewDialog.Document = myDocument; printPreviewDialog.ShowDialog();"
  4. Run project.
  5. Click button to open PrintPreviewDialog.
  6. Tab through to Zoom and change zoom's value.
  7. 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.

Eudora-Li01 avatar Feb 29 '24 07:02 Eudora-Li01

@LeafShi1 can your team take a look and see what might be happening here?

merriemcgaw avatar Mar 05 '24 19:03 merriemcgaw

This issue no longer repro in .NET 9.0.100-preview.1.24101.2:

wfd-i-3978-2

Related code was changed very recently, which may have solved the issue:

image

ricardobossan avatar Mar 13 '24 17:03 ricardobossan

Closing the issue, as it no longer repro on latest version.

ricardobossan avatar Mar 13 '24 17:03 ricardobossan

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

Eudora-Li01 avatar Mar 14 '24 02:03 Eudora-Li01

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

LeafShi1 avatar Mar 20 '24 10:03 LeafShi1

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

Philip-Wang01 avatar Mar 28 '24 02:03 Philip-Wang01