Re: canvas toDataUrl() works in mouse event but not in touch event

2013-11-16 Thread James Bearden
OK, I rolled the code out to production and borrowed a newer android phone 
and it works like a champ. Go team. I still don't understand why, but oh 
well.

James

On Saturday, November 16, 2013 10:45:58 AM UTC-6, James Bearden wrote:
>
> Thank you for the reply, but I don't quite follow. That bug seems to refer 
> to toDataURL not working at all for certain Android versions, but that 
> isn't the issue I have. My issue is that it works sometimes (in a mouse 
> event) but not others (in a touch event).
>
> On Friday, November 15, 2013 12:58:41 PM UTC-6, Jim Douglas wrote:
>>
>> https://code.google.com/p/android/issues/detail?id=7901
>>
>> On Friday, November 15, 2013 9:36:21 AM UTC-8, James Bearden wrote:
>>>
>>> Hello,
>>>
>>> I have implemented a signature widget using the GWT 2.5 Canvas. It works 
>>> great on the desktop (mouse event), but not on a tablet (touch event). 
>>> Unfortunately the only table I have available for testing is an Android 
>>> 2.3.4 tablet. 
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: canvas toDataUrl() works in mouse event but not in touch event

2013-11-16 Thread James Bearden
Thank you for the reply, but I don't quite follow. That bug seems to refer 
to toDataURL not working at all for certain Android versions, but that 
isn't the issue I have. My issue is that it works sometimes (in a mouse 
event) but not others (in a touch event).

On Friday, November 15, 2013 12:58:41 PM UTC-6, Jim Douglas wrote:
>
> https://code.google.com/p/android/issues/detail?id=7901
>
> On Friday, November 15, 2013 9:36:21 AM UTC-8, James Bearden wrote:
>>
>> Hello,
>>
>> I have implemented a signature widget using the GWT 2.5 Canvas. It works 
>> great on the desktop (mouse event), but not on a tablet (touch event). 
>> Unfortunately the only table I have available for testing is an Android 
>> 2.3.4 tablet. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: canvas toDataUrl() works in mouse event but not in touch event

2013-11-15 Thread Jim Douglas
https://code.google.com/p/android/issues/detail?id=7901

On Friday, November 15, 2013 9:36:21 AM UTC-8, James Bearden wrote:
>
> Hello,
>
> I have implemented a signature widget using the GWT 2.5 Canvas. It works 
> great on the desktop (mouse event), but not on a tablet (touch event). 
> Unfortunately the only table I have available for testing is an Android 
> 2.3.4 tablet. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


canvas toDataUrl() works in mouse event but not in touch event

2013-11-15 Thread James Bearden
Hello,

I have implemented a signature widget using the GWT 2.5 Canvas. It works 
great on the desktop (mouse event), but not on a tablet (touch event). 
Unfortunately the only table I have available for testing is an Android 
2.3.4 tablet. So here is my code snippet:

  _canvas.setTabIndex(tabIndex);
  _canvas.addStyleName("neoheader");
  _canvas.setSize(width + "px", height + "px");
  _canvas.setCoordinateSpaceHeight(height);
  _canvas.setCoordinateSpaceWidth(width);

  final Context2d context = _canvas.getContext2d();
  context.setLineWidth(2);
  context.setStrokeStyle(CssColor.make(0,0,0));

  _canvas.addMouseMoveHandler(new MouseMoveHandler() {
  public void onMouseMove(MouseMoveEvent event) {
if (_drawing) {
  int thisX = event.getRelativeX(_canvas.getElement());
  int thisY = event.getRelativeY(_canvas.getElement());
  if (_lastX >= 0 && _lastY >= 0) {
_exists = true;
context.beginPath();
context.moveTo(_lastX, _lastY);
context.lineTo(thisX, thisY);
context.stroke();
  }
  _lastX = thisX;
  _lastY = thisY;
}
  }
});
  _canvas.addMouseDownHandler(new MouseDownHandler() {
  public void onMouseDown(MouseDownEvent event) { _drawing = true; }
});
  _canvas.addMouseOutHandler(new MouseOutHandler() {
  public void onMouseOut(MouseOutEvent event) { 
_lastX = -1;
_lastY = -1;
_drawing = false; 
_canvas.setFocus(false);
if (_exists) _handler.sigChanged(_canvas.toDataUrl());
  }
});
  _canvas.addMouseUpHandler(new MouseUpHandler() {
  public void onMouseUp(MouseUpEvent event) { 
_lastX = -1;
_lastY = -1;
_drawing = false; 
_canvas.setFocus(false);
if (_exists) _handler.sigChanged(_canvas.toDataUrl());
  }
});
  
  _canvas.addTouchMoveHandler(new TouchMoveHandler() {
  public void onTouchMove(TouchMoveEvent event) {
if (event.getTouches().length() > 0) {
  Touch touch = event.getTouches().get(0);
  int thisX = touch.getRelativeX(_canvas.getElement());
  int thisY = touch.getRelativeY(_canvas.getElement());
  if (_lastX >= 0 && _lastY >= 0) {
_exists = true;
context.beginPath();
context.moveTo(_lastX, _lastY);
context.lineTo(thisX, thisY);
context.stroke();
  }
  _lastX = thisX;
  _lastY = thisY;
}
event.preventDefault();
event.stopPropagation();
  }
});
  
  _canvas.addTouchStartHandler(new TouchStartHandler() {
  public void onTouchStart(TouchStartEvent event) { 
event.preventDefault();
  }
});
  
  _canvas.addTouchEndHandler(new TouchEndHandler() {
  public void onTouchEnd(TouchEndEvent event) {
if (_exists) {
  _lastX = -1;
  _lastY = -1;
  _canvas.setFocus(false);
  _handler.sigChanged(_canvas.toDataUrl());
  com.google.gwt.user.client.Window.alert("onTouchEnd: " + 
_canvas.toDataUrl());
}
event.preventDefault();
  }
});

As I said it works flawlessly in a desktop web browser using mouse events, 
but on the tablet _canvas.toDataUrl() always returns "data:," even though 
the canvas has been visibly drawn on. Any help would be greatly appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.