iOSFocusEvents.cs 1.15 KB
Newer Older
Mattia's avatar
Mattia committed
1
using System;
Mattia's avatar
Mattia committed
2
using SampleApp.DependencyServices;
Mattia's avatar
Mattia committed
3 4 5 6
using Xamarin.Forms;
using SampleApp.iOS;
using Xamarin.Forms.Platform.iOS;

Mattia's avatar
Mattia committed
7
[assembly: ExportRenderer(typeof(IFocusEvents), typeof(iOSFocusEvents))]
Mattia's avatar
Mattia committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
namespace SampleApp.iOS
{
    public class iOSFocusEvents : ImageRenderer
    {

        protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                SetNativeControl(new CustomButton());
            }
        }

        
        


    }

    public class CustomButton : FormsUIImageView
    {
        

        public CustomButton() : base()
        { 
            Console.WriteLine("Custom button created");
        }



        public override void AccessibilityElementDidBecomeFocused()
        {
            base.AccessibilityElementDidBecomeFocused();
            
            Console.WriteLine("Ding Dong");
            
        }

        public override void AccessibilityElementDidLoseFocus()
        {
            base.AccessibilityElementDidLoseFocus();
            Console.WriteLine("Campanello ha perso il focus");

        }




    }
}