winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Add Click Through behavior to `ToolStrip`/`MenuStrip`

Open elachlan opened this issue 1 year ago • 14 comments

Fixes #9288 Fixes #9240 Fixes #9277 Fixed #2544

Unsure on the attributes for the new property and whether or not an auto implemented property is okay.

I went with 'AllowClickThrough' because I thought it was more self documenting.

My development environment isn't fully setup yet so this was a very quick pr without any testing.

Microsoft Reviewers: Open in CodeFlow

elachlan avatar Jun 23 '23 01:06 elachlan

@merriemcgaw here is the PR.

elachlan avatar Jun 23 '23 01:06 elachlan

My assumption here is that MenuStrip inherits from ToolStrip and so it should also get the property and behavior.

elachlan avatar Jun 23 '23 01:06 elachlan

I have been able to test it and it looks like its working.

elachlan avatar Jun 23 '23 01:06 elachlan

@rickbrew here is the ToolStrip ClickThrough changes if you wanted to review.

elachlan avatar Jun 23 '23 02:06 elachlan

Can we have a global/static property for this, or at least to configure the default property value? This seems like a property that will be set to the same value for everything in an app — it would be unusual to have a mix of values throughout an app’s UI, in other words. It would be easy to accidentally not set the property on a new piece of UI, resulting in bug churn. Or maybe some kind of inherited property ala WPF, where we set the property at the top of the UI tree and all the child controls use that for their default value.

rickbrew avatar Jun 23 '23 16:06 rickbrew

Excellent point. I am unsure how to go about that. I'll have to ask the team what they prefer and for an example.

elachlan avatar Jun 23 '23 21:06 elachlan

... resulting in bug churn

BTW this is not theoretical -- I found a bug just a few months ago where a top-level ToolStrip was not using click-through (with my modified WndProc). It had been like that for years and nobody noticed / reported it. It was the only piece of UI that wasn't using it.

rickbrew avatar Jun 23 '23 22:06 rickbrew

... resulting in bug churn

BTW this is not theoretical -- I found a bug just a few months ago where a top-level ToolStrip was not using click-through (with my modified WndProc). It had been like that for years and nobody noticed / reported it. It was the only piece of UI that wasn't using it.

Yes, those kinds of bugs suck. We do need a centralised method of switching it.

elachlan avatar Jun 23 '23 22:06 elachlan

Thanks @elachlan. team will review PR this week and share feedback.

dreddy-work avatar Jun 26 '23 17:06 dreddy-work

This is awaiting API review. Now that we are in .NET 9, we plan on going through all our API suggestions in the beginning of the new year. Thank you for your patience!

lonitra avatar Nov 20 '23 23:11 lonitra

Needs to solve conflicts. Otherwise LGTM.

ricardobossan avatar Dec 27 '23 22:12 ricardobossan

@ricardobossan we are waiting on an API review from the team to get this included in .NET9.

elachlan avatar Dec 27 '23 22:12 elachlan

@elachlan we'll be getting those API reviews early in the new year!

merriemcgaw avatar Dec 29 '23 23:12 merriemcgaw

@merriemcgaw Just checking this is still on the radar?

elachlan avatar Mar 14 '24 02:03 elachlan

Thanks for the ping @elachlan I do want this in .NET 9 for sure!

@lonitra / @JeremyKuhne can you guys get the API through review? Should we get this in now with a Preview flag while they are pending the official review?

merriemcgaw avatar Mar 14 '24 22:03 merriemcgaw

@lonitra can you please review this? API has been approved!!

elachlan avatar Jul 03 '24 23:07 elachlan

Codecov Report

Attention: Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 74.59186%. Comparing base (2a6733d) to head (e76fda0). Report is 18 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main       #9349         +/-   ##
===================================================
+ Coverage   74.55540%   74.59186%   +0.03645%     
===================================================
  Files           3040        3041          +1     
  Lines         629493      629688        +195     
  Branches       46835       46839          +4     
===================================================
+ Hits          469321      469696        +375     
+ Misses        156818      156624        -194     
- Partials        3354        3368         +14     
Flag Coverage Δ
Debug 74.59186% <16.66667%> (+0.03645%) :arrow_up:
integration 17.96192% <16.66667%> (-0.00812%) :arrow_down:
production 47.52611% <16.66667%> (+0.02471%) :arrow_up:
test 96.97607% <ø> (+0.02160%) :arrow_up:
unit 44.56790% <16.66667%> (+0.04910%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

codecov[bot] avatar Jul 04 '24 00:07 codecov[bot]