Bedeviled By ControlSets

Hey guys,

I’ve got a control set on a page of about 40 subclassed WebCanvases.

Problem is none of these canvases is showing up when I open the page. And when I go and look at the properties of the page in the debugger, this control set is simply not there.

I’m stumped as to what the problem is…All the events and associated methods are firing.

[quote=187726:@Jon Ogden]Hey guys,

I’ve got a control set on a page of about 40 subclassed WebCanvases.

Problem is none of these canvases is showing up when I open the page. And when I go and look at the properties of the page in the debugger, this control set is simply not there.

I’m stumped as to what the problem is…All the events and associated methods are firing.[/quote]

You would not be trying to use the desktop ‘new’ method to add them dynamically to the webpage by any chance ? Because it does not work in Web Edition.

Nope. All the controls are already laid out on the page. And I’ve created a control set in the IDE.

Could be something other than the control set. Have you tried taking the controls out of the control set ?

Yes. Multiple times. Even re-created the subclasses from scratch.

So when they are not in the Control set, do they show ?

I did try it with one of the canvases and it did not. I think it did show up in the debugger properties though. But nothing showed on the screen.

Looks like something may be wrong that is not control set related. I just tried a simple webcanvas with g.drawpicture in the paint event, in a control set, it displays just fine.

Check your paint code. Also, you may want to set a backcolor webstyle and see if the canvases show up.

I suppose you have checked visibility already.

Yes to all. Not sure what’s going on then. I’ll keep digging.

You mentioned subclassed webcanvas. Could it be that ? When such things happen, you want to start with one, and ascertain it works, before adding 39 others.

Not entirely sure. I’ve created an entirely new page and added some controls onto of my subclass and so far that does appear to be working but I’m not quite sure where the problem was on my other pages. Now, it is odd, that even on the working page, the control group still does NOT show up in the properties/variables list of the window in the debugger.

OK. I’m getting my canvases showing up but I’m not getting consistent painting of the images in the browser. Sometimes they show sometimes they don’t.

I’ve always had this problem and it’s very frustrating that Xojo can’t produce a better web canvas who’s paint event actually paints the picture in question…

[quote=187779:@Jon Ogden]OK. I’m getting my canvases showing up but I’m not getting consistent painting of the images in the browser. Sometimes they show sometimes they don’t.

I’ve always had this problem and it’s very frustrating that Xojo can’t produce a better web canvas who’s paint event actually paints the picture in question…[/quote]

If all you need to do is to display images, or a minimum of drawing, a WebImageView is probably a better idea. It is also way faster. I compared the two ; for drawing, WebCanvas produces much finer details. It seems able to use the full screen resolution.

Here is a project that compare both. Upon run it displays the same picture in both controls. WebCanvas is at least twice as slow to display the picture. Then when you press the button, the same pattern is drawn to WebCanvas g object in Paint, and to a picture displayed in the WebImageView. WebCanvas result is much finer. This shows each has its advantages, and should be picked accordingly.

http://RubberViews.com/xojo/WebCanvasViewCompare.zip

Well, I can’t even get images that are simple, small PNGs to display in canvases in Web Edition - well at least not consistently.

I already moved to using the ImageView and it works much better.

The Canvas in desktop is so awesome and powerful. The canvas in Web is nothing more than an etch-a-sketch tool for drawing simple lines. Pathetic.

[quote=187799:@Jon Ogden]Well, I can’t even get images that are simple, small PNGs to display in canvases in Web Edition - well at least not consistently.

I already moved to using the ImageView and it works much better.

The Canvas in desktop is so awesome and powerful. The canvas in Web is nothing more than an etch-a-sketch tool for drawing simple lines. Pathetic.[/quote]

By its very nature, Web Edition is quite different than desktop. Sure, at first glance, it feels the same, and as Geoff pointed out once to me, Xojo’s goal is to make it as much as possible the same as Desktop, with the same controls. Problem is, technology is not the same. There is a world of differences between a good old desktop screen and a browser.

There is also the habit of never using Image Well on Desktop that made Canvas the universal way of displaying pictures. Very often, though, using a backdrop image makes little difference. Problem is, WebCanvas does not have a backdrop.

Then there is the issue of latency. Drawing on a canvas takes but a few microseconds. In the best conditions, it takes hundredths of seconds if not tenth of seconds on WE. And even more in real life hosting conditions ; close to a second in general. That is where a WebImageView is clearly superior. But what is pathetic is that unlike the Japanese, we often don’t have 100 Megabits bandwidth available, and even less their planned 1000 Megabits.

What my little test project clearly shows, though, is how good WebCanvas is at drawing lines. Even if it is darn slow at it.

I understand what you are saying completely. However, if they can get images to display in an image view control, it should be able to be done in a canvas.

I just took your project and made a control group of the canvases and created about 36 of them. It took about 13 seconds for the images to all load. Nothing loaded until after 10 seconds. Now, I’m surprised they actually did load. I get cases where some images never load. But then again, there’s more code running in my app and more stuff going on.

I don’t think it should take 13 seconds to load a picture that is 148 kB in size into 60 pixel x 60 pixel canvases. Something is just not right there. And that is ONE picture. If you have different pictures for each canvase it gets even worse…

Yes, canvases are great at drawing lines. But these days showing graphical content and pictures is what it is all about.

And yes, in my case I was able to use an image view. Fortunately, I’m not having to do anything other than show the picture really. On the desktop, I do a little more with this part of the app and so having the capabilities of the canvas is important.

And then to not even have a control set visible in the properties of the web page - I don’t understand that. I know control sets in web are quite a bit different but unless you have an array property of the defined type in your window, you have no way of viewing the properties of the items in the control set.

[quote=187882:@Jon Ogden]I understand what you are saying completely. However, if they can get images to display in an image view control, it should be able to be done in a canvas.

I just took your project and made a control group of the canvases and created about 36 of them. It took about 13 seconds for the images to all load. Nothing loaded until after 10 seconds. Now, I’m surprised they actually did load. I get cases where some images never load. But then again, there’s more code running in my app and more stuff going on.

I don’t think it should take 13 seconds to load a picture that is 148 kB in size into 60 pixel x 60 pixel canvases. Something is just not right there. And that is ONE picture. If you have different pictures for each canvase it gets even worse…

Yes, canvases are great at drawing lines. But these days showing graphical content and pictures is what it is all about.

And yes, in my case I was able to use an image view. Fortunately, I’m not having to do anything other than show the picture really. On the desktop, I do a little more with this part of the app and so having the capabilities of the canvas is important.

And then to not even have a control set visible in the properties of the web page - I don’t understand that. I know control sets in web are quite a bit different but unless you have an array property of the defined type in your window, you have no way of viewing the properties of the items in the control set.[/quote]

Just like in Desktop, WE uses native controls. From what I can tell by the pages DOM code, it uses HTMLCanvas. https://en.wikipedia.org/wiki/Canvas_element

The HTMLCanvas has a picture property, it would seem trivial for Xojo to provide a backdrop property. I frankly do not understand why Xojo decided to force the paint event on users to display pictures. See http://www.w3schools.com/html/html5_canvas.asp for doing that in JavaScript. It should be light years faster.

Talking about fast, nothing is probably faster than the good old IMG HTML Tag

<img style="width: 233px; height: 200px;" alt="" src="file:///Users/Mitch/Documents/Match_Software/schoolfonts.com/htdocs/images/ZNuscriptOutlineGuided.jpg">

Better yet, it resizes automatically the picture to make it fit, unlike ImageView. That is probably by far the fastest way of displaying images. It should not be very difficult to use a Web Control Wrapper to create your own custom control based on it.

I do understand your frustration. It seems a part of what is happening to you can be avoided by going straight to the HTML Control instead of letting Xojo impose an additional layer of complexity.

[quote=187898:@Michel Bujardet]

I do understand your frustration. It seems a part of what is happening to you can be avoided by going straight to the HTML Control instead of letting Xojo impose an additional layer of complexity.[/quote]

If I wanted to program in html, I wouldn’t use Xojo.

Shouldn’t a framework provide a GOOD version of a control?

[quote=187922:@Jon Ogden]If I wanted to program in html, I wouldn’t use Xojo.
Shouldn’t a framework provide a GOOD version of a control?[/quote]

Indeed in an ideal world, there should be no need for declares in Desktop and iOS, nor JavaScript or HTML and CSS in Web Edition. That said, WebImageView is a pretty decent implementation of HTML IMG. If only the HTML Width and Height had been exposed, it would allow pictures to fill automatically the control, whereas today one has to scale them.

I find Xojo WE to do a rather good job at abstracting the complexity of HTML/CSS/Javascript into the Xojo language. For the little I know of what lies underneath, the achieved simplicity is amazing.

I would not say it is not good onto itself ; more often used poorly because of the assumption it will work like the desktop one rather than intrinsically bad. From what I see, WebCanvas is an implementation of HTML Canvas, which has no backdrop, just DrawImage.

I never said one should program in HTML rather than Xojo. But nothing wrong about custom controls and declares, right ? The point is not to have good or bad controls, it is to understand the best adequation for a given job. Like programming on Mac requires a minimum of knowledge about the Cocoa framework, knowing what is under WE controls is the way to obtain the best results. For images, WebImageView is definitely better ; and using preloaded images is key for speedy display.

What I sincerely regret is that the documentation spends very little time explaining all that, and it has to be discovered often by trial and error.