Bug 33516 - Override UITextView.TextContainerInsert, UITextView.Changed event no longer fires
Summary: Override UITextView.TextContainerInsert, UITextView.Changed event no longer f...
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.10
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-08-31 14:10 UTC by dj_technohead
Modified: 2015-09-03 02:33 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description dj_technohead 2015-08-31 14:10:57 UTC
After overriding the UITextView.TextContainerInset property with the below:

public override UIEdgeInsets TextContainerInset 
		{
			get
			{
				return base.TextContainerInset;
			}
			set
			{
				base.TextContainerInset = value;
			}
		}


The UITextView.Changed event no longer gets triggered. Commenting out the above and it fires again.
Comment 1 dj_technohead 2015-08-31 14:12:41 UTC
Getting rid of the override keyword, and it fires again.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-09-01 07:30:11 UTC
Does this prevent the Changed event from triggering as well?

> [Export ("textContainerInset")]
> public override UIEdgeInsets TextContainerInset 
> {
>     get
>     {
>         return base.TextContainerInset;
>     }
>     set
>     {
>         base.TextContainerInset = value;
>     }
> }
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-09-01 07:30:55 UTC
Remove the 'override' keyword, like this instead:

    [Export ("textContainerInset")]
    public new UIEdgeInsets TextContainerInset 
    {
        get
        {
            return base.TextContainerInset;
        }
        set
        {
            base.TextContainerInset = value;
        }
    }
Comment 4 dj_technohead 2015-09-01 14:31:22 UTC
Hi Rolf,
   having the Export attribute (regardless of the presence of override or new) has the same effect, that is the Changed event does not get triggered.

   The working solution is as follows:

	public UIEdgeInsets TextContainerInset 
		{
			get
			{
				return base.TextContainerInset;
			}
			set
			{
				base.TextContainerInset = value;
			}
		}


   Curious as to know what's the difference?

thanks,
Dennis
Comment 5 dj_technohead 2015-09-01 14:34:20 UTC
The above should have the new statement, but does work, but obviously throws a warning.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2015-09-02 02:57:17 UTC
It looks like iOS is checking if you're implementing the textContainerInset selector, and in that case doesn't call the Changed event.

Try adding this as well, and see if that makes the Changed event work again:

	public override bool RespondsToSelector (Selector sel)
	{
		if (sel.Name == "textContainerInset")
			return false;
		
		return base.RespondsToSelector (sel);
	}
Comment 7 dj_technohead 2015-09-02 19:05:55 UTC
Hi Rolf,
   I tried adding the RespondsToSelector method, but that was causing the app to crash. I then tried to create a new project to give to you so that you could look at it and test, but it is not showing the same problem. That is the Changed event is being raised. The real project has a lot more overrides of the UITextView so it could be any combination of them.  I have a working workaround, so I guess I am good.

thanks,
Dennis
Comment 8 Rolf Bjarne Kvinge [MSFT] 2015-09-03 02:33:48 UTC
OK, I'll close this then. Feel free to reopen if you need more help and/or is able to create a test project for us.