How to make full window canvas in GWT?
I am using the built in canvas widget (javadoc) and wondering how to make it take 开发者_如何学编程the full browser window.
I tried setting 100% width and height and removing all padding and margins, for body,html and canvas. I have 3 problems: 1. I checked with chrome's dev tools and the clean.css seems to override myproject.css 2. Even after those css rules and removing the margin on the body in the dev tools, there is still a vertical scrollbar. 3. I struggle a bit with the fact that the canvas coordinate space is independent of actual pixel size. The mause events give me pixel location. Is there a way to get events in coordinate space "pixels"?After another 4 hours of fiddling I found the answer, and decided to share:
1. I saw that the way i used to load css was deprecated so i used client bundle
2. This was my main problem, solved by explicitly disabling scrollbars
Window.enableScrolling(false);
3. setting just the coordinate space will automatically adjust pixel size to it.
So basically for a full window canvas: 100% width and height and 0px margin in css for html and body. Adjusting coordinate space to client size in the on resize event and explicitly disabling scorllbars.
精彩评论