Subclass a MobileContainer

Why can’t I subclass a MobileContainer?

Because UI can’t be inherited.

You’ve got two options:

  1. Create a generic class and set its super to MobileContainer. That will let you add code but not UI. Then when you want to use it, drag a mobileContainer from the library and change its super to your class name.
  2. Or… use nested containers.

But I can on Desktop.

Can you explain a little more what you are doing on Desktop that you can’t on Mobile?

That is not possible. Neither in iOS nor in Android projects.

1 Like

On Desktop I have created a container (let’s call it “MyContainer”) that, in effect, knows all about its controls. The container contains the code to clear all the controls, read from the database and save to the database. MyContainer is subclassed from DesktopContainer. It contains no UI items (it’s a blank container).

Then I subclass that and arrange any needed controls. That container goes onto the window. The window knows how to talk to any containers it has.

There’s an XDC presentation about this.

Ah, for me I can’t change the super to CustomMobileContainer on iOS project, I get this:
screencast2024-01-1909-27-14-ezgif.com-video-to-gif-converter

and reverts back to MobileContainer.

Exactly.

It is now clear for me, you can subclass a MobileContainer but you can’t change the super for a new MobileContainer to CustomMobileContainer.

Is there an Issue for this in Issues?


Edit: found the Issue
#73975 - Cannot create MobileContainer sublasses that have no layout editor

Not true, you can’t subclass a MobileContainer.

Isn’t this a subclass?

I mean, I can’t use it as I can’t assignt this CustomMobileContainer but is a subclass, no?


Edit: I guess you are using the ‘long’ way to do it:

  • add a regular class
  • change the super to MobileContainer

instead of select the MobileContainer from the Library, right click and select ‘New Subclass’
image

How you did it? I get the Messagebox you shown above.

I edited my post above. Direct Subclass from the library control as I always do.

1 Like

Yes. You can in fact make a subclass of a MobileContainer, but you can’t (at least I can’t) do anything useful with it. Like place controls on it. (Unless I’ve missed something real basic.)

1 Like

No, you did not miss something basic. MobileContainer has a bug (not present in iOSContainerControl), see the Issue I posted above and make sure that you select thumbs up.

I don’t use Mobile but I do hope this is fixed for 2024r1.