I'm making a kind of paintbrush program with a c++ builder. The program works well with mouse, but there's a recognition problem when I draw with a tablet especially writing letters.
I submit the image of program. Same things are written with mouse and tablet pen.
I think I found the reason of the problem. When I quickly repeat MouseDown and MouseUp with the tablet pen, the program recognizes it mouse move so short line is drawn instead of two dots.
So I have to make program recognize the MouseUp event as soon as pen is separated form the tablet like mouse does.
Is there any way to recognize mouse up happened except MouseClick->false or MouseUp event? I already tried to use switch the variable in MouseDown and MouseUp events but it doesn't work.
'''
void __fastcall TForm1::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
{
Image1->Picture->Bitmap->Canvas->MoveTo(X,Y);
pt_x=X;
pt_y=Y;
if (Button == mbLeft){
if(type==0){ //penmode
Image1->Picture->Bitmap->Canvas->Pen->Color = ColorDialog1->Color;
PenColor = ColorDialog1->Color;
}
else if(type==1) //erasermode
{
Image1->Picture->Bitmap->Canvas->Pen->Color = clWhite;
PenColor = clWhite;
}
}
else if (Button == mbRight) //eraser mode for right click
{
Image1->Picture->Bitmap->Canvas->Pen->Color = clWhite;
PenColor = clWhite;
}
Image1->Picture->Bitmap->Canvas->Pen->Width = ScrollBar1->Position;
PenWidth = ScrollBar1->Position;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
if(Shift.Contains(ssLeft))
{
Image1->Picture->Bitmap->Canvas->MoveTo(pt_x,pt_y);
Image1->Picture->Bitmap->Canvas->LineTo(X,Y);
pt_x=X;
pt_y=Y;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
{
MouseClick=false;
}
//---------------------------------------------------------------------------
'''