PDFium Component Docs

PopupMenu 속성

이 API 항목은 식별자, 시그니처, 코드 블록, PDF 용어를 원래 형태로 유지합니다.
컴포넌트: TPdfView  ·  유닛: PDFium
TPopupMenu를 PDF 뷰어에 연결하여 page를 오른쪽 클릭하면 context menu가 나타나도록 합니다

구문

property PopupMenu: TPopupMenu; // published, inherited from TControl

설명

PopupMenu를 설정하면 뷰어가 같은 form에 놓인 TPopupMenu component와 연결됩니다. 사용자가 뷰어 안에서 오른쪽 클릭을 하거나 keyboard menu key를 누를 때마다 VCL/LCL이 cursor 위치에 메뉴를 자동으로 보여 주며, application이 직접 WM_CONTEXTMENU를 처리할 필요는 없습니다

일반적인 PDF reader context menu에는 Copy Selected Text, Zoom In, Zoom Out, Fit Width, Rotate, Go to Page…, Find…, Save As… 같은 항목이 있습니다. 메뉴 항목은 보통 CurrentCharIndex, Zoom, FitMode, Rotation, PageNumber 같은 public property를 읽거나 써서 document에 작동합니다

팝업은 OnContextPopup mechanism을 통해 표시되므로, OnContextPopup을 처리하고 Handled := True로 설정해 동적으로 억제하거나 바꿀 수 있습니다. 이는 오른쪽 클릭이 자체 menu가 필요한 form field나 annotation 위에서 발생할 때 유용합니다

비고

예제

// Attach a context menu offering Copy / Fit Width / Go to Page
procedure TForm1.FormCreate(Sender: TObject);
begin
  PdfView1.PopupMenu := pmReader;
end;

procedure TForm1.miFitWidthClick(Sender: TObject);
begin
  PdfView1.FitMode := pfmFitToWidth;
end;

procedure TForm1.miGoToPageClick(Sender: TObject);
var S: string;
begin
  S := IntToStr(PdfView1.PageNumber);
  if InputQuery('Go to page', 'Page number:', S) then
    PdfView1.PageNumber := StrToIntDef(S, PdfView1.PageNumber);
end;

참고 항목

AllowUserTextSelection, CurrentCharIndex, PageNumber, FitMode