QuickMenu
is a convenient annotation popup menu that appears when a user long-presses on a blank space or on text contained in a PDFViewCtrl
. It extends RelativeLayout
and is a child view of PDFViewCtrl
.
Action
Menu
Long-press on blank space
Long-press on text
To learn more about each icon, see the icon cheat sheet .
To learn how to customize the quick menu, see the customize quick menu guide . A number of events may be raised when a user interacts with the quick menu. For example, events will be raised when the quick menu is shown, dismissed, or when a quick menu item is clicked. You can register a QuickMenuListener
to listen to such events and implement custom behavior accordingly.
If your activity is using PdfViewCtrlTabHostFragment2
for viewing PDF files, you can set your listener by calling:
Java Kotlin
1 mPdfViewCtrlTabHostFragment. getCurrentPDFViewCtrlFragment ()
2 . addQuickMenuListener ( new ToolManager. QuickMenuListener () {
3 @ Override
4 public boolean onQuickMenuClicked ( QuickMenuItem menuItem) {
5 int which = menuItem. getItemId ();
6 // Handle click event...
7 // Return true to stop executing internal logic
8 return true ;
9 }
10
11 @ Override
12 public void onQuickMenuShown () {
13 // Called when the quick menu is shown
14 }
15
16 @ Override
17 public void onQuickMenuDismissed () {
18 // Called when the quick menu is dismissed
19 }
20 });
1 mPdfViewCtrlTabHostFragment !! . getCurrentPDFViewCtrlFragment ()
2 . addQuickMenuListener (object : ToolManager . QuickMenuListener {
3 override fun onQuickMenuClicked (menuItem: QuickMenuItem ): Boolean {
4 val which = menuItem.itemId
5 // Handle click event...
6 // Return true to stop executing internal logic
7 return true
8 }
9
10 override fun onQuickMenuShown () {
11 // Called when the quick menu is shown
12 }
13
14 override fun onQuickMenuDismissed () {
15 // Called when the quick menu is dismissed
16 }
17 })
Or you can register the listener using the ToolManager
by calling ToolManager.setQuickMenuListener
:
Java Kotlin
1 mToolManager. setQuickMenuListener ( new ToolManager. QuickMenuListener () {
2 @ Override
3 public boolean onQuickMenuClicked ( QuickMenuItem menuItem) {
4 int which = menuItem. getItemId ();
5 // Handle click event...
6 // Return true to stop executing internal logic
7 return true ;
8 }
9
10 @ Override
11 public void onQuickMenuShown () {
12 // Called when the quick menu is shown
13 }
14
15 @ Override
16 public void onQuickMenuDismissed () {
17 // Called when the quick menu is dismissed
18 }
19 });
1 mToolManager !! . setQuickMenuListener (object : ToolManager . QuickMenuListener {
2 override fun onQuickMenuClicked (menuItem: QuickMenuItem ): Boolean {
3 val which = menuItem.itemId
4 // Handle click event...
5 // Return true to stop executing internal logic
6 return true
7 }
8
9 override fun onQuickMenuShown () {
10 // Called when the quick menu is shown
11 }
12
13 override fun onQuickMenuDismissed () {
14 // Called when the quick menu is dismissed
15 }
16 })
If there are tools that you would like to remove from the quick menu, you can hide them by calling ToolManager.disableToolMode
:
Java Kotlin
1 // Disable TextSquigglyCreate tool, TextStrikeoutCreate tool
2 mToolManager. disableToolMode ( new ToolMode []{
3 ToolManager.ToolMode.TEXT_SQUIGGLY,
4 ToolManager.ToolMode.TEXT_STRIKEOUT}
5 );
1 mToolManager !! . disableToolMode ( arrayOf (ToolManager.ToolMode.TEXT_SQUIGGLY, ToolManager.ToolMode.TEXT_STRIKEOUT))
Then, when you long-press on text you will see:
Icon
ToolMode
RECT_CREATE
OVAL_CREATE
POLYLINE_CREATE
POLYGON_CREATE
CLOUD_CREATE
LINE_CREATE
ARROW_CREATE
RULER_CREATE
TEXT_CREATE
CALLOUT_CREATE
TEXT_ANNOT_CREATE
INK_CREATE
INK_ERASER
SIGNATURE
STAMPER
RUBBER_STAMPER
FREE_HIGHLIGHTER
TEXT_HIGHLIGHT
TEXT_UNDERLINE
TEXT_SQUIGGLY
TEXT_STRIKEOUT
ANNOT_EDIT_RECT_GROUP
If you would like to hide the long press quick menu entirely, you can do so by calling ToolManager.setDisableQuickMenu
. For example:
Java Kotlin
1 mToolManager. setDisableQuickMenu ( true );
1 mToolManager !! . setDisableQuickMenu ( true )