PictureBox and Text


#1

I am using the demo version and trying to revive a project I did with AppStudio 1.2.5. This project was HEAVILY dependent on adding text to Picture Boxes. It doesn’t appear that I can do that anymore. Is that the case? The Handbook still says it is possible, but I tried several methods listed below that didn’t work:

PictureBox1.fillText = "great"
PictureBox1.strokeText = "great"
PictureBox1.textContent = "Great"
PictureBox1.print = "GREAT"
PictureBox1.innerHTML = “

This is big text


(I am not sure the last one is the correct way to code it, but it worked to print text on the form).

There is no Property associated with the PictureBox in the Properties list, in the handbook, or in the dropdown in the code window that allows text anymore. I know I have written code to print text in the Container tool, but it would be a huge chore to go through a project of this size and redo every PictureBox into a container.

Any ideas?

alan


#2

PictureBox hasn’t changed - text still works.

Have a look at the PictureBox sample. It writes some text. My hunch is that you’re trying to update the PictureBox itself, not the context:

pb = PictureBox1.getContext("2d");
pb.textBaseline = "top";
pb.font = "16px sans-serif";
pb.fillText("This is a picturebox", 100, 0);

#3

George,
Thanks, that did work. Adding
pb = PictureBox1.getContext(“2d”);
made it work. Why? The explanatioon may be what you are trying to say, but I still don’t get it. My old code worked well and that line of code was not present anywhere. I am unsure exactly why it is necessary. Could you explain? In case you didn’t notice I am not a pro! (LOL)

alan


#4

I’m glad it is working for you now. AppStudio 1.2.5 is from 7 years ago: I can’t remember how the control worked back then. PictureBox is a wrapper for the HTML5 Canvas control, which has always used a context for drawing text, graphics and images.

http://wiki.nsbasic.com/PictureBox