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

Mattia's avatar
Mattia committed
8
[assembly: ExportRenderer(typeof(CustomImage), typeof(iOSFocusEvents))]
Mattia's avatar
Mattia committed
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
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();
            
Mattia's avatar
Mattia committed
45 46

            Functionality4.myLabel.Text = "Bell Image Has Focus";
Mattia's avatar
Mattia committed
47 48 49 50 51
        }

        public override void AccessibilityElementDidLoseFocus()
        {
            base.AccessibilityElementDidLoseFocus();
Mattia's avatar
Mattia committed
52 53
            Functionality4.myLabel.Text = "Bell Image does not have focus";
            
Mattia's avatar
Mattia committed
54 55 56 57 58
        }




Mattia's avatar
Mattia committed
59

Mattia's avatar
Mattia committed
60 61
    }
}