Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Canvas Script

Reply
Thread Tools

Canvas Script

 
 
Tyrone Slothrop
Guest
Posts: n/a
 
      08-09-2011
I have created a copy of this example:
http://devfiles.myopera.com/articles/649/example2.html
to which I have added a function which will generate the coordinates
of the drawing to a hidden field.

The client would like the continuation of the drawing of the line
should mouseout and mousedown are both true, that is if someone is
drawing and strays off the canvas and returns. In the example URL,
you can see (at least in FF) is you leave and return to canvas, a line
is created between the point of mouseout and mouseover when mousedown
is true. Since the purpose of the canvas script is to create a
signature, this is undesireable.

To fix the mouseout problem, I added a listener which terminates the
line onmouseout. However, I am at a loss as to how to restart the
drawing when pointer returns to the canvas. Since only one event can
be defined by addEventListener, it is not possible to listen for both
mouseover and mousedown.

Perhaps I am approaching this the wrong way. The intent is to remove
the connecting line when the pointer returns to the canvas. What
really is needed is a way to terminate and restart without having to
add another listener.

Anyone have an suggestions?

TIA
 
Reply With Quote
 
 
 
 
Dr J R Stockton
Guest
Posts: n/a
 
      08-10-2011
In comp.lang.javascript message <v4s047parfjon7uqaeee9eigsimctigp8h@4ax.
com>, Mon, 8 Aug 2011 17:10:36, Tyrone Slothrop <>
posted:

>Perhaps I am approaching this the wrong way. The intent is to remove
>the connecting line when the pointer returns to the canvas. What
>really is needed is a way to terminate and restart without having to
>add another listener.
>
>Anyone have an suggestions?


As a palliative if nothing better turns up, you might be able to draw,
every 50 ms, a background coloured line along the inside of the border
of the canvas, so eradicating the offending line. It will of course
only work if exit and entry are on the same side.

Alternative possible palliative - put a thick dark border around the
inside of the edge of the canvas, and ask the user to keep within the
hole in the middle. Then most users will learn to stay on the canvas.

P.S. : I have read your page source. You can add Chrome (and, I am
told, IE9) to the "Good" list.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE8 FF3 Op12 Sf5 Cr12
news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>.
<http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
 
Reply With Quote
 
 
 
 
Tyrone Slothrop
Guest
Posts: n/a
 
      08-14-2011
On Wed, 10 Aug 2011 20:24:57 +0100, Dr J R Stockton
<> wrote:

>In comp.lang.javascript message <v4s047parfjon7uqaeee9eigsimctigp8h@4ax.
>com>, Mon, 8 Aug 2011 17:10:36, Tyrone Slothrop <>
>posted:
>
>>Perhaps I am approaching this the wrong way. The intent is to remove
>>the connecting line when the pointer returns to the canvas. What
>>really is needed is a way to terminate and restart without having to
>>add another listener.
>>
>>Anyone have an suggestions?

>
>As a palliative if nothing better turns up, you might be able to draw,
>every 50 ms, a background coloured line along the inside of the border
>of the canvas, so eradicating the offending line. It will of course
>only work if exit and entry are on the same side.
>
>Alternative possible palliative - put a thick dark border around the
>inside of the edge of the canvas, and ask the user to keep within the
>hole in the middle. Then most users will learn to stay on the canvas.
>
>P.S. : I have read your page source. You can add Chrome (and, I am
>told, IE9) to the "Good" list.


I am told that iPad and similar devices will also work, though my
Android has had some issues with it.

The thought about the thick border gave me an idea. Training people
how to do it right is not really an option when they are exposed to
this script once or maybe twice (and the user does not need additional
challenges after having answered nearly 100 questions). However,
adding another div around the canvas with a unique id might provide
the opportunity to add a second listener to reinitiate the drawing
tools. I don't have the time top flesh this out at the moment (my
wife seems to think I belong to her on the weekends) but, if the user
has the mousedown when crossing the containing div, the tool could
reintiate on mouseover the canvas. I think. Maybe.

Any comments or other (more feasible) thoughts?
 
Reply With Quote
 
Tyrone Slothrop
Guest
Posts: n/a
 
      08-14-2011
On Wed, 10 Aug 2011 20:24:57 +0100, Dr J R Stockton
<> wrote:

>In comp.lang.javascript message <v4s047parfjon7uqaeee9eigsimctigp8h@4ax.
>com>, Mon, 8 Aug 2011 17:10:36, Tyrone Slothrop <>
>posted:
>
>>Perhaps I am approaching this the wrong way. The intent is to remove
>>the connecting line when the pointer returns to the canvas. What
>>really is needed is a way to terminate and restart without having to
>>add another listener.
>>
>>Anyone have an suggestions?

>
>As a palliative if nothing better turns up, you might be able to draw,
>every 50 ms, a background coloured line along the inside of the border
>of the canvas, so eradicating the offending line. It will of course
>only work if exit and entry are on the same side.
>
>Alternative possible palliative - put a thick dark border around the
>inside of the edge of the canvas, and ask the user to keep within the
>hole in the middle. Then most users will learn to stay on the canvas.
>
>P.S. : I have read your page source. You can add Chrome (and, I am
>told, IE9) to the "Good" list.


I created a hack by adding 20px padding to the canvas block.
Originally, I had added a background and a border around the canvas in
the style sheet. In the revised version, I created a filled rectangle
with a stroke. Now, when the user leaves the edge of the canvas
within 20px padding, the line drawing will continue.

It is not a perfect fix, but it works.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to couper contenier of a canvas in an outer canvas??? olsr.kamal@gmail.com Python 10 03-15-2013 08:46 PM
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
Canvas with scrollbars - how to get correct canvas coordinate when the scroll bars have moved? PhilC Python 2 10-25-2004 11:57 AM
Canvas scrolling - scrollBar become "disabled" on change in canvas Askari Python 2 08-30-2004 02:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57