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
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.
[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!
Thank you in the assistance of sorting the issue!
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 (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.
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=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.
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