Backdrop

Shao, you are brilliant. This is exactly what was going on. If an image is called backdrop (whatever the name of the file), it won’t display.

40151 - Window Backdrop does not display in run and build when picture is named “backdrop”
Status: Needs Review Rank: Not Ranked Product: Xojo Category: N/A

Michel Bujardet Today at 8:27 AM

OS: Windows 8

Xojo: Xojo 2015r2.2

Steps: This was discovered after a discussion in https://forum.xojo.com/24097-backdrop

In Windows (not tested in Mac but I suspect it is the same), if a picture is dragged in the IDE and named “backdrop” (whatever the name of the file), it displays in the IDE but not upon Run or in the build.

It may have to do with the internal name of the picture for backdrop.

The quickest way would be to modify the LR to indicate not to use that name, but it may be best to fix that so using “backdrop” for the backdrop picture no longer present the bug.

<https://xojo.com/issue/40151>

[quote]40151 - Window Backdrop does not display in run and build when picture is named “backdrop”
Status: Needs Review Rank: Not Ranked Product: Xojo Category: N/A [/quote]

Ha!
“It’s easy when you know how”
I’d never suspect naming would be an issue!
The file was initially named “backdrop.bmp”. The gif was named “backdrop-gif.gif” and then renamed by Xojo to “backdropgif” when dragged in to the IDE.

Hmm… It would be an easy move to just make a note in the LR not to name a n image “backdrop”. At least until the error is fixed in the IDE. It would have saved me the headache some 8 months ago!

Maybe the BMP is working after all, with the different name! :slight_smile:
Thank you in the assistance of sorting the issue!

Just tested on Mac : same punishment.

Jakob:

did you noticed that the image that worked for you was named backdropgif, not backdrop ?

Try renaming your images as something more useful for you and avoid the word backdrop (or Backdrop).

Usually, Xojo IDE rename conflicting names, but you may walked in dangerous area…

The problem is not just pictures named backdrop but named anything matching a member of the current scope.

Try setting a picture named ‘title’ as the backdrop from within the Window. The Title property of the Window takes precedence causing a type-mismatch error.

If there’s no name conflict then the project picture is used…

[code]Module Module1
Sub setBackdrop()
//no backdrop member of Module1 so the project picture is assigned
MainWindow.Backdrop = backdrop
End Sub
End Class

Window MainWindow
Sub Open()
Module1.setBackdrop
End Sub
End Window[/code]

Maybe there could be a way to force looking outside of local scope first :slight_smile: (jk)

self.Backdrop = notself.backdrop

Easiest is to rename your project picture so it doesn’t match anything in the places you might use it.

BTW: I had a (tux) Linux image in one project and get errors “missing image”.

It tooks me a while to discover that the IDE renamed my Linux dropped image to Linux1.

Linux is a used name.

Try to prefix your image with a space…

So it’s not a bug then. Just an issue of scope. It is rather unfortunate that it compiled, but the compiler saw

main.backdrop = main.backdrop

which is quite legitimate, although nonsensical. If you initialized it in app.open, it would probably work. Setting it in the IDE would not work, because the IDE produces code that runs in the scope of the window. It might be nice if the IDE or compiler disallowed using the name (in the inspector), but since it isn’t a reserved word, I don’t know how feasible that would be.

I have added that to the feedback case.

[quote=201135:@Tim Hare]So it’s not a bug then. Just an issue of scope. It is rather unfortunate that it compiled, but the compiler saw

main.backdrop = main.backdrop

which is quite legitimate, although nonsensical. If you initialized it in app.open, it would probably work. Setting it in the IDE would not work, because the IDE produces code that runs in the scope of the window. It might be nice if the IDE or compiler disallowed using the name (in the inspector), but since it isn’t a reserved word, I don’t know how feasible that would be.[/quote]

Nope. Even in Open, self.backdrop = backdrop does not display the picture. Any reference to backdrop seems to simply apply to the window property, not the picture.

[quote=201158:@Michel Bujardet]I have added that to the feedback case.

Nope. Even in Open, self.backdrop = backdrop does not display the picture. Any reference to backdrop seems to simply apply to the window property, not the picture.[/quote]

In general naming a project item the same name as the property you want to assign it to IS going to have issues
Its more than just backdrop that experiences this

A picture, when dragged into a project, results in a global method with the name of the image - so in this case “backdrop”
And, the IDE, basically write code out that sets

        control.backdrop = backdrop

But this is within the scope of the Window - so control.backdrop refers to the controls property and “backdrop” refers to the Windows backdrop property

You can try this in your own code
Set the back drop of the window to an image named “foo”
And the back drop of the control to an image named “backdrop”
Hit run

The control (in the code I wrote its a canvas) shows the back drop from the window

[quote=201167:@Norman Palardy]In general naming a project item the same name as the property you want to assign it to IS going to have issues
Its more than just backdrop that experiences this

A picture, when dragged into a project, results in a global method with the name of the image - so in this case “backdrop”
And, the IDE, basically write code out that sets

        control.backdrop = backdrop

But this is within the scope of the Window - so control.backdrop refers to the controls property and “backdrop” refers to the Windows backdrop property

You can try this in your own code
Set the back drop of the window to an image named “foo”
And the back drop of the control to an image named “backdrop”
Hit run[/quote]

The logic is perfectly clear. I did report the issue because obviously, it would be necessary to warn users not to do such a thing as using a property name for their pictures. As well as probably anything dragged into the project.

until recently there wasn’t even a decent way to avoid this in the code the IDE wrote

The addition of the Global keyword makes it possible to fix

See case 39970 which is similar in nature

And you can get all kinds of fun errors
Try using the name of the image set to “frame” , “visible” etc
Now that you know WHY this causes and error the compilation errors you’ll get will make sense

Oh … and this is fixed for a future release :stuck_out_tongue:

Warning additions goes to the doc ?