감사드립니다. 이를 위해서는 기본 TCustomPaintBox32 클래스의 공개 (하지만 게시되지 않은) 속성을 조정해야합니다.
뭔가
ImgView.Options := ImgView.Options + [pboWantArrowKeys];
등이 TImgView32 클래스 (여기라는 이름의 ImgView)는 화살표 키를 캡처 할 수 있습니다. OffsetRect가 왼쪽/오른쪽 및 위/아래로 델타 (2 층과 3 인자)를 추가하여 TFloatRect을 조정
procedure TMainForm.ImgViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Location: TFloatRect;
begin
if Assigned(FSelection) then
case Key of
VK_LEFT:
FSelection.Location := OffsetRect(FSelection.Location, -1, 0);
...
:
일단 당신이 같은 키보드 핸들러를 작성할 수있었습니다.
위 예제에서 FSelection은 현재 선택된 레이어입니다. 레이어를 선택한 후 (마우스 클릭으로) 저장되었습니다. 또한 선택자로 TRubberBandLayer를 사용하는 경우 고무 밴드 위치를 조정해야 할 수도 있습니다.
부록 : OffsetRect의
구현 :
function OffsetRect(const Rct: TFloatRect; const DeltaX, DeltaY: TFloat): TFloatRect;
begin
Result.TopLeft := OffsetPoint(Rct.TopLeft, DeltaX, DeltaY);
Result.BottomRight := OffsetPoint(Rct.BottomRight, DeltaX, DeltaY);
end;
이 또는 당신이 직접이 같은 코드를 사용할 수 있습니다
procedure TMainForm.ImgViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Location: TFloatRect;
begin
if Assigned(FSelection) then
case Key of
VK_LEFT:
FSelection.Location := FloatRect(FSelection.Location.Left - 1, FSelection.Location.Top, FSelection.Location.Right - 1, FSelection.Location.Bottom);
...
하지만 조금 추한 보인다.
부록 2 : 라이브러리 이전 버전
(예를 들어, 1.9.x)는 OffsetPoint 기능뿐만 아니라 누락 될 수 있습니다.
function OffsetPoint(const Pt: TFloatPoint; DeltaX, DeltaY: TFloat): TFloatPoint;
begin
Result.X := Pt.X + DeltaX;
Result.Y := Pt.Y + DeltaY;
end;
http://graphics32.org/documentation/Docs/Units/GR32_Layers/Classes/TLayerCollection/Methods/Delete.htm –
감사 : 이것은로 구현됩니다. 레이어 삭제가 완료되었습니다. 내 다른 문제는 어때? 키 이벤트 캡처? 키보드 화살표를 사용하여 레이어를 어떻게 움직일 수 있습니까? – user1137313
잘 모르겠다. 컨트롤이이를 지원합니까? –