Overriding iOSControl.Visible

I have subclassed an iOSRectangle and overridden the Visible() method. Is there any way to call the Super method from within the overridden method?

This is the code currently in visible:

[code]
Dim child As iOSControl
For i As Integer = 0 To self.ControlCount-1

child = self.Control(i)
child.Visible = bool

Next i

Super.Visible = bool[/code]

However, this generates the error:
“This item does not exist super.super.Visible = bool”

Equally, removing the “super” results in a stackoverflow, presumably calling itself. Would it be best to implement this with a different method name (e.g. hideControlChildren(), so that the iosRectangle.Visible can be called?

Visible isn’t a method
It’s a property
They’re not virtual
So you’ve shadowed the super class’ visible property - not overridden it
And this often leads to problems

What you do is not called overriding but shadowing. The code should be as follows in your subclass’s computed property:

iOSRectangle(Self).Visible = bool

Note that you have to be very careful how to call Visible from now on:

[code]Dim rect As YouriOSRectangle = New YouriOSRectangle()
rect.Visible … // runs the code in your subclass

Dim rect As iOSRectangle = New iOSRectangle()
rect.Visible … // does NOT run the code in your subclass[/code]
The latter for example can happen when you loop over all iOSRectangle or all iOSControls and you forget to cast to YouriOSRectangle.

This issue IMHO is one of the biggest drawback of Xojo. When you subclass built-in controls it is not possible to catch assignments to important properties like Enabled, Visible, and a few others.

I still don’t understand why this issue has not been addressed yet, as it is important to make proper subclasses of built-in controls. This could be done by changing these computed properties to method pairs (with Assigns it wouldn’t break existing code), or by introducing events like: Enabled, Disabled, VisibilityChanged, and so on.

A-ha, that clears things up! Thanks guys, your answers are much appreciated! Hopefully my newbieness will lessen.

Although, I hadn’t intended to shadow the original property, I’d implemented an interface that included

Function Visible() As Boolean

And

Function Visible(Assigns bool As Boolean)

Not intentionally shadowing the original property, just practically. I thought it might be comfortable with Visible the property and Visible() the method. Though your answers will definitely keep me from repeating the same mistakes in future (hopefully)!