Create a New Picture Property: Default


for some forgotten reason, I was asking mysel: how can I add a Default value to the Picture Property I just add to Window1 ?

The Add a Property area.

The Picture Property undocumented field (“Default”).

As naive as I can be sometimes, I put in the Default field of a newly created Picture Property a default value:

500,500 (500,500) 500
(one text line at a time)

and at last I got an information:

“Type mismatch error. Expected Picture, but got int32.”

[Still naive): how do I paste an image into a text field ?

Then, I had a flash of genius: drop a picture into my project and paste its name into the Default field ?
Nope: wrong thinking:

“A constant was expected here, but this is other kind of expression.”

The (rhetorical) question is: How do we work with this field ?

The error codes are telling you what you want to know. A picture object needs a picture. I don;t know what you are expecting from 500, 500. I guess those are the .top and .left properties of your picture object, but they don’t define a picture.

You don’t. Unless you purchase the Formatted Text Control from BKeeney or some other canvas-based editfield control which will allow that. Use a canvas to hold your properly defined picture.

I think the question should be, why does a picture property allow you to enter a default value in the inspector pane of the IDE.

I think the answer is, the default field is there for properties that can be assigned a default value with a string, constant or expression, such as a string, integer, double or color. The field should be hidden or disabled for other property types, but alas, it is not. (Unless there really is some special purpose that I am unaware of)

You can set the value of the picture property in the constructor or open event of the window.


I certainly was bad to explain what I wanted and the fact I was not able to display the image in my original post may not add to clarity.

So, use cmd-P to add a new Property, then type a Property Name, Fill the Property Type (Picture) and then you are in the Default area I was talking to.

Because that field hold text, I was searching what to give it, so my use of “500”. It was only at the third try (500) that I got the correct error message.

Also, I do not understand what / how “Formatted Text Control” comes into this conversation about the creation of a Property in Window1.

At last, you are right, I use Xojo 2013r4.1: no EditField there. And I never talked about Canvas Class nor TextField (and Childs) Class…

Sorry for the mistake, thank you for taking time to answer.

A Picture is a an object - thus a variable declared as a Picture has a default value of “nil” - meaning no object assigned.

Same holds true, for example, for the Dictionary class. I often forget to initialize it. What you could do: Create a computed property, and in the getter first check if it is available. If it is - return it - if not: create it first and then return it.

Emile - your exact words were:

And my answer is that you cannot. I was attempting to tell you other ways to display an image. The FTC WILL allow you to display a picture within a textArea. As an alternative, you can use a canvas.


you forgot the context: Create a Property.

I was not talking about “how can I place an image in a TextArea” just like I can do it with TextEdit or Word or…

The Conversation title states this perfectly: Create a New Picture Property: Default.

I am sorry to not have been clear enough.

Hi all,

After reading your reactions, I certainly was wrong in my question somewhere.

First of all, I was not able to set the image, so here is a link to it (49KB):

Secondly, this is a Property. Type cmd-option-P to create one, then fill the following fields:
Default :

The whole question is around the Default field. As far as I understand it (after a bad night) is: you have to place a constant in that field. That constant have to hold a Picture. The question relates to that: how can I set a constant to a Picture so I can put it there (in the Default field of the Property).

Also, I do not found a description for that in the Docs.

This is what you’re talking about right?

Yes, Jim, I could not show it here (nor in my MacBook Pro from the internet…). MediaFire troubles I suppose.

The highlited field is what I am talking about.

THANK you for displaying the image. I wasted one hour on that ! One hour of my time !

I’m pretty sure that you can’t assign a default value to a picture property. It always starts as nil. You can assign a default value to a number or string or boolean using a constant with the &…but that doesn’t work for pictures. I think the Default field should be disabled for types that can’t be assigned a default value. I would call it an oversight… maybe start a bug report/ feature request.

You can’t assign a default value for a property where the data type is Object or subclass thereof. You can assign Nil, but this is the default value anyway for such properties, so you best leave it empty.