iOSFocusEvents.cs 1.23 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
using Xamarin.Forms;
using SampleApp.iOS;
using Xamarin.Forms.Platform.iOS;
Mattia's avatar
Mattia committed
6 7
using SampleApp.Views;
using SampleApp.Models;
Mattia's avatar
Mattia committed
8

Mattia's avatar
Mattia committed
9
[assembly: ExportRenderer(typeof(IFocusEvents), typeof(iOSFocusEvents))]
Mattia's avatar
Mattia committed
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
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
46 47

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

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




    }
}