Thanks for responding.
Thanks in advance for any help.
Since I have posed two questions at once, if it's all the same to
everyone, I'd like to focus on my issue with canvas first.
What's goes wrong when I try to make a Canvas part of a view using
uibinder?
If I code something like this, I see a Canvas with the appropriate
stuff drawn on it. But (see below)...
public void onModuleLoad() {
SimpleLayoutPanel pnl = new SimpleLayoutPanel();
Canvas cvs = Canvas.createIfSupported();
pnl.add(cvs);
RootLayoutPanel.get().add(pnl);
Context2d ctx = cvs.getContext2d();
int w = cvs.getCoordinateSpaceWidth();
int h = cvs.getCoordinateSpaceHeight();
ctx.setFillStyle("#d53747");
ctx.moveTo(0, 0);
ctx.lineTo(w, h);
ctx.beginPath();
ctx.arc(w/2, h/2, 9, 0, Math.PI * 2.0, true);
ctx.closePath();
ctx.fillText("Yay!!", w/2, h/2 + 20);
ctx.fill();
}
if I code something like this:
(1) Here's the uibinder declaration.
<g:SimpleLayoutPanel addStyleNames="{style.pnl}" ui:field="pnl">
<c:Canvas ui:field="cvs" />
</g:SimpleLayoutPanel>
(2) Here's the corresponding field in the view class:
@UiField
Canvas cvs;
(3) And of course, Canvas needs this:
@UiFactory public Canvas getCvs() {
return Canvas.createIfSupported();
}
Then do the same drawing, nothing appears on the Canvas. It remains
blank. It has size. Nothing is null. No errors are thrown.
Context2d ctx = vw.getCtx();
int w = vw.getCvs().getCoordinateSpaceWidth();
int h = vw.getCvs().getCoordinateSpaceHeight();
ctx.setFillStyle("#d53747");
ctx.beginPath();
ctx.arc(10, 10, 9, 0, Math.PI * 2.0, true);
ctx.closePath();
ctx.fillText("Yay!!", w/2, h/2 + 10);
ctx.fill();
On Sep 19, 3:26 am, Alexandre Dupriez <
alexandre.dupr...@gmail.com>
wrote: