Jump to content

TW3Image.enabled problem

Recommended Posts

I created a form with an TW3Image (W3Image1) and a TW3Button (W3Button1). Then, I added the following code in InitializeObject:
W3Button1.enabled := false;
W3Image1.enabled  := false;
writeln('W3Button1 enabled: ' + W3Button1.enabled.tostring);
writeln('W3Image1 enabled: ' + W3Image1.enabled.tostring);

This is what I get in the console when I execute the project:


W3Button1 enabled: False [line #3143]
W3Image1 enabled: True [line #3143]



It seems that the enabled property of TW3Image cannot be changed...

Link to post
Share on other sites
  • Administrators

InitializeObject is the wrong place to initialize your components.


The reason is that the DOM isn't fully created at this stage, so the properties you set wont be properly stored in the DOM element the object represents.



Use InitializeForm instead.

Link to post
Share on other sites
  • Administrators

The InitializeObject method is intended for "Self".


I.e., component developers can override this method to set initial properties for the class's own fields.

Since this is triggered at a very early stage, there's no guarantee that all other DOM elements are created.

The method is introduced in the base class TW3TagObject.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...