LuckyDucko / Mopups

Popups For MAUI
BSD 3-Clause "New" or "Revised" License
268 stars 49 forks source link

CloseWhenBackgroundIsClicked=True does not work on iOS #41

Closed tranb3r closed 1 year ago

tranb3r commented 1 year ago

CloseWhenBackgroundIsClicked=True does not work on iOS. Unless you also set BackgroundInputTransparent=True, but then the click is passed to the element that is visible, which is probably not what you want to do.

On the sample project:

No issue on Android.

Could you please take a look? Thanks

jakob-reesalu commented 1 year ago

Got the same problem here!

jpsaccount commented 1 year ago

Got the same problem. Any updates?

Sumn3rd commented 1 year ago

Finding the same problem on Windows.

Interesting enough if you set: CloseWhenBackgroundIsClicked to false; & InputTransparent to true, it allows the clickthrough to background at the cost of losing access to content on the popup.

Inside version 1.1.0 It would seem that: BackgroundClickedCommand is always null inside popup.cs - meaning the if CanExecute condition is never true, preventing the command to fire but stopping the null exception.

LuckyDucko commented 1 year ago

Found a simple fix for iOS which I will add.

In the iOS mopups section, we have the "PopupWindow" file.

This file is used so we can hook and override the HitTest function of a popupwindow, so we can determine if the popupwindow was hit or not.

When it determines if it should send a background click, I just added in an extra check for CloseWhenBackgroundIsClicked, so it should sort out the iOS one.

Windows I dont have access to a windows computer right now to poke at, but in PopupPageRenderer there is the following screenshot, I would toy around with that, as it is attached to the pointer pressed event.

Screenshot 2023-01-12 at 10 27 44
LuckyDucko commented 1 year ago

@tranb3r @jakob-reesalu @jpsaccount

If you guys want to download the repo, and link Mopups to your app instead of using the nugget, could verify if you believe its a fix for the issue.

PaulMDemers commented 1 year ago

I am also experiencing the issue under MacCatalyst.

tranb3r commented 1 year ago

@LuckyDucko It now behaves like if BackgroundInputTransparent is always True, which is probably not what we want, is it?

LuckyDucko commented 1 year ago

It does? I'll do some more testing, but i did test and and could confirm there is a difference between the two.

tranb3r commented 1 year ago

I've tested the sample AswinPage, on iOS, and when I click on the background, the popup does close now, but the click is propagated to the element behind, even if BackgrouInputTransparent is false.

vccosenza commented 1 year ago

someone already mentioned this but the issue exists in Mac catalyst as well. Other than the CloseWhenBackGroundClicked issue, these popups work much nicer than the community toolkit for my apps needs. Could we get a Mac catalyst fix?

LuckyDucko commented 1 year ago

@tranb3r

Give it one more test, I did a more in depth dive.

it turns out that when I perform a a HitTest, if you return null to that hit test, under the hood iOS attempts to find the next ui interact-able element to fire off, which is why the previous fix wasn't working.

@vccosenza & @PaulMDemers

I added the same fix to MacCatayst, however, on my computer MacCatalyst seems broken? is it just the sample app that works this way?

vccosenza commented 1 year ago

@LuckyDucko In the latest of the sample app, I am seeing Mac catalyst close instantly after the popup opens. The latest Nuget version I have installed in my project though this is not the case and works really well other than the background close issue

tranb3r commented 1 year ago

@tranb3r Give it one more test, I did a more in depth dive.

Yes, it think it works now. Thanks!

PaulMDemers commented 1 year ago

Just tested the sample app on Catalyst, the windows do appear and disappear. However they appear to move as soon as the mouse moves and are not waiting for a click.

Click, no mouse move -> shows -> mouse move -> vanishes

Poking the code a bit, it looks like HitTest() is being called for the mouse movement events.

PaulMDemers commented 1 year ago

I modified the HitTest function in the MacCatalyst PopupWindow.

Changed: formsElement.SendBackgroundClick();

to: if(uievent?.ButtonMask != 0) formsElement.SendBackgroundClick();

On line 40, this appears to correct the issue for me.

LuckyDucko commented 1 year ago

Thanks guys, sorted on latest release https://github.com/LuckyDucko/Mopups/releases/tag/v1.1.1

RichardMarsh commented 1 year ago

Thank you for this!