OOP and GUI Design

Hello,

I am new to Xojo so please forgive me if there is an obvious answer to my question…

I watched the basics of OOP in Xojo. OOP for methods and properties are of a medium importance for me. But, IMHO, OOP shines when it comes to GUI development.

For example, can I do this in Xojo:

  1. Create a WebContainer class,
  2. Add a few WebControls to that container,
  3. Create subclasses of the container. The subclass should include all controls from the super/base class/container.

Another example,
How can I change style or behavior of all WebTextFields in my application? With OOP I would change style/behavior of the super/base class, and all subclasses would inherit from it.

Thanks in advance,
Stan

No
UI Layout is NEVER inherited in any Xojo project

If you want something like this, Create a container with the controls the way you want them and then create a new WebContainer and place the first on the second.

Thank you Guys!

Hmmm, OOP works to a certain extend for UI - just on a basic level, I guess. Here is what I did:

  1. I created a subclass of WebTextField named: WebTextField_1,
  2. I created a subclass of WebTextField_1 named: WebTextField_2,
  3. I added code to the Shown event of WebTextField_1.
  4. I put both WebTextField_1 and WebTextField_2 on a web page and the code was executed on both controls.
    GREAT!

However,

  1. I cannot set any properties of WebTextField subclasses (I have to put the control on a webpage or container to be able to modify any property, like, size, style etc., and that precludes subclassing)

  2. I can create subclasses of containers, but they don’t inherit controls.

[Create a container with the controls the way you want them and then create…]

Yes, I will have to figure out a methodology.

I was really looking forward to using OOP in UI development. It would help me with consistency and quick UI changes across the whole app… I will have to figure out how to handle it…

S.

[quote=323323:@Stan F]Thank you Guys!

Hmmm, OOP works to a certain extend for UI - just on a basic level, I guess. Here is what I did:

  1. I created a subclass of WebTextField named: WebTextField_1,
  2. I created a subclass of WebTextField_1 named: WebTextField_2,
  3. I added code to the Shown event of WebTextField_1.
  4. I put both WebTextField_1 and WebTextField_2 on a web page and the code was executed on both controls.
    GREAT!
    [/quote]
    This is normal stuff - implementing the event (SHOWN) in the Superclass (WebTextField_1) means that it and any subclasses will have that code for the SHOWN event.
    see http://developer.xojo.com/userguide/classes
    and http://developer.xojo.com/userguide/properties-methods-and-events

What you cannot do is create an entire layout, then subclass that and have that entire layout and controls available in the subclass

Right click your super & sub class & select “Inspector Behaviour”
see http://developer.xojo.com/userguide/desktop-custom-controls

No - this would be “inheriting UI” which will not work