# SelectionTextMode can't be toggle (in mobile)

**URL:** <https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [June 21, 2024, 4:52am UTC](https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326 "2024-06-21T04:52:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![huanglvming](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@huanglvming](https://pdfjs.community/u/huanglvming)\
**Post date:** [June 21, 2024, 4:52am UTC](https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326/1 "2024-06-21T04:52:04Z")

</div>

**Which product are you using?**

PDF.js Express

**PDF.js Express Version**

8.1.0

**Detailed description of issue**  
when i click selectTextButton, the viewer turns to text selection mode, but when i click the button again, text selection mode can’t be toggle, so when i touch the mobile screen, the pdf text will be selected.

**Expected behaviour**  
text selection mode should be toggle when i click selectionTextButton

**Does your issue happen with every document, or just one?**  
it happens anyway when in mobile

**Link to document**

> **[Display & View Documents using PDF.js Express | Documentation](https://pdfjs.express/documentation/samples/viewing)**

**Code snippet**

```javascript
          WebViewer(
            {
              licenseKey: 'zSbyd7VXHHiO0AP6DxNO',
              path: '/webviewer/lib',
              initialDoc: pdfUri,
              css: '/pdf.css',
              disabledElements: [
                'leftPanelTabs',
                'menuButton',
                'panToolButton',
                'viewControlsButton',
                'selectToolButton',
              ],
            },
            viewerRef.current
          ).then((instance: any) => {
            // now you can access APIs through the WebViewer instance
            const { Core, UI } = instance
            console.log('instance', instance)
            // adding an event listener for when a document is loaded
            Core.documentViewer.addEventListener('documentLoaded', () => {
              UI.setSideWindowVisibility(!isMobile)
            })
            // adding an event listener for when the page number has changed
            // Core.documentViewer.addEventListener(
            // 'pageNumberUpdated',
            // (pageNumber: number) => {
            // console.log(`Page number is: ${pageNumber}`)
            // }
            // )
            Core.documentViewer.addEventListener('mouseLeftUp', (e: any) => {
              // !!selectTxt.length && instance.UI.openElements([modalOptions.dataElement])
              instance.UI.textPopup.update(textPopupButtons)
            })
            Core.documentViewer.addEventListener(
              'textSelected',
              (quads: any, selectedStr: string, pageNumber: number) => {
                selectedText = selectedStr
              }
            )

            // adds a button to the header that on click sets the page to the next page
            if (showCupture && !isMobile) {
              UI.setHeaderItems((header: any) => {
                header.get('searchButton')
                header.insertBefore({
                  type: 'actionButton',
                  img: iconFullSize,
                  onClick: () => {
                    onCupture()
                  },
                })
              })
            }
          })

```

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [June 21, 2024, 4:34pm UTC](https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326/3 "2024-06-21T16:34:56Z")

</div>

Hi there,

Could you please clarify what you mean by selectTextButton?  
Are you able to reproduce this in the demo? [PDF.js Viewer Demo | PDF.js Express](https://pdfjs.express/demo)

Best regards,  
Kevin Kim

---

<div class="post-metadata">

**Author:** ![huanglvming](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@huanglvming](https://pdfjs.community/u/huanglvming)\
**Post date:** [June 24, 2024, 2:16am UTC](https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326/4 "2024-06-24T02:16:10Z")

</div>

This is the button, which can’t be toggle. Neither can the demo you gave.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/5/5fb5addd5878b1e4afafd130962fdbe20f77ad02.png)

please help me solve the problem, it‘s important to me.

Thanks.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [June 24, 2024, 4:20pm UTC](https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326/5 "2024-06-24T16:20:24Z")

</div>

I am still unable to see that button on the demo:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/2/26b66ab7b2ac4bc5198cb2bd87e4b48e3faf554c.png)

However, if you need to enable that button, you can do this via

```javascript
instance.UI.setToolMode(Tools.ToolNames.TEXT_SELECT)

```

Best regards,  
Kevin Kim

---

<div class="post-metadata">

**Author:** ![huanglvming](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@huanglvming](https://pdfjs.community/u/huanglvming)\
**Post date:** [June 25, 2024, 2:38am UTC](https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326/6 "2024-06-25T02:38:55Z")

</div>

Thank you for your reply, but it still doesn’t solve my problem.

1. When you switch to iPhone mode (the picture shows that you were in iPad mode), you can see the button.
2. What I want is not just to enable the button, but to disable the button when I click it again (it cannot be disabled once it is turned on).

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [June 25, 2024, 10:01pm UTC](https://pdfjs.community/t/selectiontextmode-cant-be-toggle-in-mobile/3326/7 "2024-06-25T22:01:32Z")

</div>

Hi there,

I tried the different iPhone options but still didn’t see the icon

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/0/0f4026a32b336a92fe00dd77a710395ac140574e.png)

However, if you would like to toggle the button, you may need to override the default behaviour and deselect the tool via switchOut:  
[https://pdfjs.express/api/Core.Tools.Tool.html#switchOut\_\_anchor](https://pdfjs.express/api/Core.Tools.Tool.html#switchOut__anchor)

Best regards,  
Kevin Kim
