Trouble when drawing and erasing onto a canvas
Posted: Sun Sep 30, 2012 12:17 am
Hi Everyone,
I got a problem with a drawing program again...
Here is the details:
When i draw something and then i erase a part of the draw, the event click is no more catched if you click from the erased part.
The official doc say "A canvas must have a color present to receive an event".
It also say to fix this use a filled region larger than the canvas. With this, all the mouse event will be catched.
I tried this solution and it works.
- But -
If you run the DrawTest program, you click on the pen and you can see the current x, y mouse are always the preceding one.
It is not supposed to be the case because i use the "moveto" function to refresh it each time.
As a result, lines appears (from xpreviousmouse, ypreviousmouse to xcurrentmouse, ycurrentmouse) instead of just "normal draw" (it means just draw from current mouse position without any lines) Notice that all mouse click are effectively catched all time.
Now, if you remove the Filled Area and just let the canvas alone, the program run perfectly but the catching mouse problem will be there again.
The strange thing is the following: Canvas and Filled region contains EXACTLY the same code to draw !
So why the Filled Region does'nt works the same way the Canvas region ???
Thanks to anybody will explain me what's happening here...
David
I got a problem with a drawing program again...
Here is the details:
When i draw something and then i erase a part of the draw, the event click is no more catched if you click from the erased part.
The official doc say "A canvas must have a color present to receive an event".
It also say to fix this use a filled region larger than the canvas. With this, all the mouse event will be catched.
I tried this solution and it works.
- But -
If you run the DrawTest program, you click on the pen and you can see the current x, y mouse are always the preceding one.
It is not supposed to be the case because i use the "moveto" function to refresh it each time.
As a result, lines appears (from xpreviousmouse, ypreviousmouse to xcurrentmouse, ycurrentmouse) instead of just "normal draw" (it means just draw from current mouse position without any lines) Notice that all mouse click are effectively catched all time.
Now, if you remove the Filled Area and just let the canvas alone, the program run perfectly but the catching mouse problem will be there again.
The strange thing is the following: Canvas and Filled region contains EXACTLY the same code to draw !
So why the Filled Region does'nt works the same way the Canvas region ???
Thanks to anybody will explain me what's happening here...
David