locked
Stop accepting input when a view is hidden RRS feed

  • Question

  • User248472 posted

    Hello,

    I have a XF application where a button shows a new view (PopupView) and that view has a slider (MySlider). I have a mechanism that allows me to tap outside of the popup to close the window (set it's IsVisible to false).

    The problem that I am encountering is that when I am adjusting MySlider if I tap the screen with another finger it hides the PopupView with the MySlider. If I don't remove the finger that was changing MySlider value I can continue to make changes to it even though it's no longer visible.

    I have tried to set the IsEnabled of the MySlider to false when the view is not visible as well as calling the slider's Unfocus method as well. Neither of these stop the changing of the value.

    Here is what is in my PopupView's property changed handler

    void PopupView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        if (e.PropertyName == nameof(IsVisible))
        {
            if (!IsVisible)
            {
                MySlider.IsEnabled = false;
                MySlider.Unfocus();
            }
            else
            {
                MySlider.IsEnabled = true;
            }
        }
    }
    

    Thanks!

    Thursday, March 7, 2019 8:30 PM

All replies

  • User180523 posted

    Sounds like a bug in your popup class to tell ya the truth. Might try an established popup framework like rg.plugins.popups - let them do one thing well instead of you trying to create everything.

    Thursday, March 7, 2019 8:58 PM
  • User248472 posted

    Unfortunately it's too late in our development cycle to make that kind of change.

    Thursday, March 7, 2019 9:02 PM
  • User180523 posted

    Your call. You can either spend 50+ hours making/fixing your own scratch-built popup framework. Or 10 hours doing minor massaging to shift from your existing Popup class to an established Popup class.

    It really shouldn't be a major deal since your code should already have most of the generic work done. You've done all the workflow of when/where/why to call a popup into existence. Changing namespaces of where the popup comes from should be less than 1 day's labor.

    Thursday, March 7, 2019 9:06 PM
  • User180523 posted

    I have a mechanism that allows me to tap outside of the popup to close the window (set it's IsVisible to false).

    I can continue to make changes to it even though it's no longer visible.

    Wait a minute... "Visible"... Did you really make a popup view that you make and display, then remove? Or did you just make some control on your page that is always there, but you hide? In other words... Is the popup really its own entity, or are you simulating a popup?

    Because I'm thinking that once you actually close and dispose of a true control, it has to loose focus and thus stop taking input. To get the behavior you're describing, your control would have to still exist and have focus.. which means its not really a view that you're actually disposing of. Or am I misreading {reading into} things?

    Thursday, March 7, 2019 9:13 PM
  • User248472 posted

    To get the behavior you're describing, your control would have to still exist and have focus.. which means its not really a view that you're actually disposing of.

    What you are saying is correct. It is created when the main page's XAML is loaded and is never disposed of.

    The rough implementation is:

    MainLayout.xaml:

    <AbsoluteLayout> <!-- fills the screen -->
        ...
        <local:Popup IsVisible="{Binding ShowPopup}"/> <!-- The Popup -->
        ...
    </AbsoluteLayout>
    

    Popup.xaml:

    <AbsoluteLayout  Width="200" Height="200">
        ...
        <Slider .../>
        ...
    </AbsoluteLayout>
    
    Thursday, March 7, 2019 10:24 PM
  • User180523 posted

    What you are saying is correct. It is created when the main page's XAML is loaded and is never disposed of.

    So the problem has been figured out. Terrific.

    Friday, March 8, 2019 1:14 PM