2016-12-21 64 views
1

在長按手勢上,上下文操作菜單沿選定文本出現。 但是,除非我從菜單中選擇一個選項,否則不會隱藏。上下文操作菜單在Ionic(Android)中未隱藏

首先,使上下文操作菜單,我用這個:

overflow-scroll = "true" in the ion-content. 

在CSS類中,我寫道:

-webkit-user-select: auto; 

但現在我不能隱藏它。它鎖定在我看來。即使在我的網絡視圖中的任何地方觸摸,它仍然啓用。隱藏上下文菜單我用這個:

-webkit-user-select: none; 
-khtml-user-select: none; 
-moz-user-select: none; 
-ms-user-select: none; 
user-select: none; 
-webkit-touch-callout:none; 

但仍然沒有獲得成功。這個特定的問題僅限於android。對於iOS,它工作正常。任何幫助,將不勝感激。

離子版本 - 2.1.0

更新

我終於找到了答案。

我用了以下兩種方法。第一種方法是長按選擇文本,第二種方法是刪除選擇。

  /*----------- To get selection--------*/ 

      $scope.getSelectionText = function() { 
      var text = ""; 
      if (window.getSelection) { 
       text = window.getSelection().toString(); 
       $scope.selectMode = true; 
      } else if (document.selection && document.selection.type != "Control") { 
       text = document.selection.createRange().text; 
       $scope.selectMode = true; 
      } 

      return text; 
     }; 

     /*---------------To remove selection----------*/ 

      $scope.remove = function(){ 
      if (window.getSelection) { 
       if (window.getSelection().empty) { // Chrome 
        window.getSelection().empty(); 
       } else if (window.getSelection().removeAllRanges) { // Firefox 
       window.getSelection().removeAllRanges(); 
       } 
      } else if (document.selection) { // IE? 
       document.selection.empty(); 
      } 
      }; 

並添加NG-點擊您的DIV

  <div class="selectable" ng-click="remove()"> 
       <ng-include src="activeTab.url"></ng-include> 
     </div> 

回答

0

我終於找到了答案。

我用了以下兩種方法。第一種方法是長按選擇文本,第二種方法是刪除選擇。

   /*----------- To get selection--------*/ 

       $scope.getSelectionText = function() { 
       var text = ""; 
       if (window.getSelection) { 
        text = window.getSelection().toString(); 
        $scope.selectMode = true; 
       } else if (document.selection && document.selection.type != "Control") { 
        text = document.selection.createRange().text; 
        $scope.selectMode = true; 
       } 

       return text; 
      }; 

      /*---------------To remove selection----------*/ 

       $scope.remove = function(){ 
       if (window.getSelection) { 
        if (window.getSelection().empty) { // Chrome 
         window.getSelection().empty(); 
        } else if (window.getSelection().removeAllRanges) { // Firefox 
        window.getSelection().removeAllRanges(); 
        } 
       } else if (document.selection) { // IE? 
        document.selection.empty(); 
       } 
       }; 

並添加NG-點擊您的DIV

   <div class="selectable" ng-click="remove()"> 
        <ng-include src="activeTab.url"></ng-include> 
      </div>