How to Calling Parent Method from SubClass

I have created a CustomWebTextField SubClass and this subclass will be bind to the WebTextField in my WebPage1.

In the CustomWebTextField SubClass , I would like to have some statements in the KeyPressed Event
CustomWebTextField.KeyPressed Event

Select Case details.KeyCode Case details.KeyArrowDown Self.KeyPressedArrowDownMethod // I had coded this statement wrongly. End Select

I would like the “KeyPressedArrowDownMethod” to be called in the WebPage1 instead. The “Self” is referring to the WebPage1 and not the CustomWebTextField SubClass. I do not know how to substitude this.

it seems like I need to use a Class Interface but as I am still new to Xojo environment, I still have difficulties in understanding the documentation. May anyone kind enough to help me to address this issue?

Thank you.

Hi Alvin,

a control can refer the containing page using the Page property.
So in general you can write:

But your control is defined outside the containing webpage so you must tell the compiler what kind of page the control is in.
For example if your page is named MySpecialPage, you must write:


Please note that this approach isn’t exactly object oriented and, as you can see, is also very unclean.
In your case you are defining a custom WebTextField that can be used only in a known page type that is defining a KeyPressedArrowDownMethod

A better solution is to define an event in your custom WebTextField that reports to the “outside world” a possibly relevant event i.e. something that someone else, when required, must handle.
Using this different approach you can reuse your custom control also in a page where the down arrow key must not be handled.

Best regards.

You should define an event in your custom control/class passing appropriate parameters and handle that event where the control/object is instantiated.

To do this you will create an event definition by contextual clicking on the custom control in the navigator and selecting "Add to "->Event Definition. Once this is done you’ll see that you can handle this event where you’ve placed it on your page/window/container as if it were a native control.

Of course you can subclass this class & implement the event handler there too.

I must agree with Alvin that, in some parts, the documentation isn’t clear enough or at least is not clear enough for someone approaching computer programming.

The “Events” chapter contained in the Reference Guide can be considered a little obscure:

Me vs Self is actually a topic covered by Bob in the BKeeney Video Training series:
There’s a lot of great, useful information in the training series that clears up a lot about Xojo.

If you have little or no programming experience, starting with the Language Reference or User Guide will be challenging.

The Introduction to Programming with Xojo might be a better place to start. There are also lots of videos: