Hello everybody,
I have found a code for selecting text from a canvas.
The code works fine, only there are 2 features in it
that I don't want. And that's the Shift and Ctrl-functions.
For example: when the user holds down the Shift-button
he can select multiple area's etc...
Can someone tell me which lines to delete to get ride off
these features?
Thank you in advanced...
This is the code:
(*---------------------------------------*)
procedure TForm1.ScrImage1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
c, r, i, j: Integer;
begin
AnchorX := X;
CurX := X;
AnchorY := Y;
CurY := Y;
Bounding := True;
c := (x + FontWidthPix) div FontWidthPix;
r := (y + FontHeightPix) div FontHeightPix;
if (c <= SCRCOLS) and (r <= SCRROWS) then
begin
DispCell(CsrCol, CsrRow, true);
CsrCol := c;
CsrRow := r;
DrawCursor(CsrCol, CsrRow);
// ShowStatus ;
end;
if Button = mbLeft then
if not (ssCtrl in Shift) then
for i := 1 to SCRROWS do
for j := 1 to SCRCOLS do begin
ScrBuf[i, j].Hilite := Char(chDefault);
DispCell(j, i, false);
end;
end;
(*-------------------------------------*)
procedure TForm1.ScrImage1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
i, j, xpos, ypos: Integer;
r: TRect;
begin
if Bounding then
begin
r := Rect(0, 0, 0, 0);
if (X < AnchorX) then begin
r.Left := X;
r.Right := AnchorX;
end
else begin
r.Left := AnchorX;
r.Right := X;
end;
if (Y < AnchorY) then begin
r.Top := Y;
r.Bottom := AnchorY;
end
else begin
r.Top := AnchorY;
r.Bottom := Y;
end;
for i := 1 to SCRROWS do
for j := 1 to SCRCOLS do begin
xpos := (j * FontWidthPix) - (FontWidthPix div 2);
ypos := (i * FontHeightPix) - (FontHeightPix div 2);
if PtInRect(r, Point(xpos, ypos)) then begin
if ScrBuf[i, j].Data = '' then
ScrBuf[i, j].Data := ' ';
if not (ssShift in Shift) then
ScrBuf[i, j].Hilite := Char(chReverse)
else
ScrBuf[i, j].Hilite := Char(chDEfault);
DispCell(j, i, false);
end;
end;
CurX := X;
CurY := Y;
end;
end;
(*------------------------------------------*)
procedure TForm1.ScrImage1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Bounding then
begin
Bounding := False;
CurX := X;
CurY := Y;
end;
end;
(*------------------------------------------*)
end.
Greetings,
Peter Kiers