Android
ComPDFKit PDF SDK
Guides

Interaction in the Editing Mode

 

When entering the editing mode, the PDF document will also enter the corresponding interaction status according to different operations. In different interaction status, a context menu like PopWindow will be be popped up, and the context menu will call back to different interfaces and includes different operation classes. The following are the different interaction status:

EditTextArea When selecting a text block.

EditSelectText When editing the content in the text block and long-pressing to select the text.

EditText When editing the content in the text block and clicking where the cursor is.

 

You can extend the CPDFContextMenuShowHelper and respond to different operations according to your rules. The following code will show you how to extend CPDFContextMenuShowHelper.

 

DemoContextMenuHelper contextMenuHelper = new DemoContextMenuHelper(readerView, this);
readerView.setContextMenuShowListener(contextMenuHelper);


When selecting a text block, you can use GetEditTextAreaContentView() to pop up the context menu and implement the following operations: ​

CPDFEditTextSelections Operate on the overall text. ​

CPDFPageView.operateEditTextArea(CPDFPageView.EditTextAreaFuncType.EDIT The keyboard pops up and the cursor is displayed, then users can edit the text content. ​

CPDFPageView.operateEditTextArea(CPDFPageView.EditTextAreaFuncType.DELETE Delete the selected text block.


When editing the content in the text block and selecting the text, you can use 
getEditSelectTextContentView() to pop up the context menu and implement the following operations: ​

CPDFEditTextSelections Operate on the selected text. ​
CPDFPageView.operateEditTextArea(CPDFPageView.EditTextAreaFuncType.DELETE Delete the selected text. ​
CPDFPageView.operateEditTextSelect(CPDFPageView.EditTextAreaFuncType.CUT Cut the selected text. ​

CPDFPageView.operateEditTextSelect(CPDFPageView.EditTextAreaFuncType.COPY Copy the selected text.


When editing the content in the text block and clicking where the cursor is, you can use 
getEditTextContentView() to pop up the context menu and implement the following operations: ​

CPDFPageView.operateEditText(CPDFPageView.EditTextFuncType.SELECT Select the word text where the cursor is located. Enter the EditSelectText status after using this method. ​

CPDFPageView.operateEditText(CPDFPageView.EditTextFuncType.SELECT_ALL Select all text in the text block. Enter the EditSelectText status after using this method. ​

CPDFPageView.operateEditText(CPDFPageView.EditTextFuncType.PAUSE Copy the contents of clipboard to the behind of the cursor.