HTMLViewer issue

Slow start this morning. I was trying to subclass a pushbutton with an action event with this code: WebViewer.LoadURL(On). WebViewer is a HTMLViewer. The (On) text is This works if I do not subclass the pushbutton but fails if I do.

PushButton_Off_Class.Action, line 1
This item does not exist

PushButton_On_Class.Action, line 1
Type “Int32” has no member named “LoadURL”

Have you created a WebViewer property in the subclass and assigned it somehow? Looks like there is something wrong with that.

I was thinking the subclassed PushButton_On_Class with it’s action event of WebViewer.LoadURL(On) being placed in the window with the
WebViewer would do it. WebViewer is an HTMLViewer.

Is PushButton_On_Class the subclass definition or the name of the instance of your subclass? If the former, and the Action event is defined in the subclass definition, it’s won’t know about WebViewer.

OnButton is the subclass of PushButton_On_Class . OnButton is in the window with WebViewer

WebViewer isn’t global; the subclass can’t see it. But the fix is easy: create a property on the subclass called WebViewer as HTMLViewer and then somewhere in the Window (like an open event) put

PushButton_On_Class1.WebViewer = WebViewer

Where PushButton_On_Class1 is actually the name of the instantiated subclass control in the window

The subclassed PushButton_On_Class which is OnButton is in a window with WebViewer so you cannot create a property with the same name in the window properties.

The subclass button is in the same window as the HTMLViewer. Why would it need to be global?

The Property would go on the subclass, but to avoid any confusion, do something like this:

On the subclass, declare a property myWebViewer as HTMLViewer

Then, instantiate the subclass in the window; let’s call it OnButton

In the Window’s Open event, write:

OnButton.myWebViewer = WebViewer

This assigns a reference to the subclass’s property to the actual HTMLViewer in the same window.

Note that your code in the subclass action will need to reference myWebViewer.

BTW, this all assumes you want that action event to be part of the reusable subclass. If all you really want is to access webviewer in the instantiated button’s action event, don’t put the code in the subclass, but rather add the event to the instantiated subclass’s action handler. Not sure what your intention here with subclassing the button really is.

I believe I got myself off in the weeds on this. Another approach is working much better. I did not need a super outside the window for the buttons.


Yeah, that can happen, so don’t worry about it. Starting from scratch can be the best way out.

Tim, I was looking for info on Property Attributes in the docs and found some but I’m still not sure how they are used. Do you have an example?

Not sure I’ve used this, Clifford, so I don’t think I can help you on that. Where were you looking?

When you create a property and then look under the the gear icon in the inspector.

Mmmm …

I’ve made no use of that. Perhaps someone else can give an example.

I was just curious. Thanks.