my.offUserCaptureScreen

Cancel screen capture listener event. This is usually paired with my.onUserCaptureScreen.

Sample Code

copy
    <!-- API-DEMO page/API/user-capture-screen/user-capture-screen.axml-->
    <view class="page">
      <view class="page-description">User screen capture event API</view>
      <view class="page-section">
        <view class="page-section-title">my.onUserCaptureScreen</view>
        <view class="page-section-demo">
          <view>Current status: {{ condition ? "listening on" : 'Listening off' }}</view>
          <view a:if="{{condition}}">
            <button type="primary" onTap="offUserCaptureScreen">Cancel screen capture listening event</button>
          </view>
          <view a:else>
            <button type="primary" onTap="onUserCaptureScreen">Turn on screen capture listening event</button>
          </view>
        </view>
      </view>
    </view>
copy
    // API-DEMO page/API/user-capture-screen/user-capture-screen.js
    Page({
      data: {
        condition: false,
      },
      onReady() {
        my.onUserCaptureScreen(() => {
          my.alert({
            content: 'Received user screen capture',
          });
        });
      },
      offUserCaptureScreen() {
        my.offUserCaptureScreen();
        this.setData({
          condition: false,
        });
      },
      onUserCaptureScreen() {
        my.onUserCaptureScreen(() => {
          my.alert({
            content: 'Received user screen capture'
          });
        });
        this.setData({
          condition: true,
        });
      },
    });

Dismissing Callback

• If you need to remove all event listener callback. Sample code:

copy
    my.offUserCaptureScreen();

• If you need to remove a specific callback event. Sample code:

copy
    my.offUserCaptureScreen(this.callback);