2014-06-12 3 views
0

사용자가 iPad에서 스크롤 할 수있는 전체 화면 (또는 화면의 일부) 텍스트 영역을 만들고 싶습니다.iPad에서 sencha touch 2의 스크롤 가능한 텍스트 영역

Notes.app과 비슷한 기능 : 많은 텍스트를 포함 할 수있는 화면/패널이 있으며 스크롤 할 수 있습니다.

탭하면 텍스트를 편집 할 수 있습니다. 적절한 구성 요소 또는 해결 방법이 있습니까?

감사합니다.

답변

0

내가 아는 한 Sencha Touch의 TextArea에는이 "스크롤 가능"속성이 없습니다.

Ext.define('Ext.overrides.TextArea', { 
      override: 'Ext.form.TextArea', 
      initialize: function() { 
       this.callParent(); 
       this.element.dom.addEventListener(
        Ext.feature.has.Touch ? 'touchstart' : 'mousedown', 
        this.handleTouchListener = Ext.bind(this.handleTouch, this), 
        false); 
       this.element.dom.addEventListener(
        Ext.feature.has.Touch ? 'touchmove' : 'mousemove', 
        this.handleMoveListener = Ext.bind(this.handleMove, this), 
        false); 
       this.moveListenersAttached = true; 
      }, 
      destroy: function() { 
       // cleanup event listeners to avoid memory leak 
       if (this.moveListenersAttached) { 
        this.moveListenersAttached = false; 
        this.element.dom.removeEventListener(
         Ext.feature.has.Touch ? 'touchstart' : 'mousedown', 
         this.handleTouchListener, 
         false); 
        this.element.dom.removeEventListener(
         Ext.feature.has.Touch ? 'touchmove' : 'mousemove', 
         this.handleMoveListener, 
         false); 
        this.handleTouchListener = this.handleMoveListener = null; 
       }; 
       this.callParent(); 
      }, 
      handleTouch: function(e) { 
       this.lastY = e.pageY; 
      }, 
      handleMove: function(e) { 
       var textArea = e.target; 
       var top = textArea.scrollTop <= 0; 
       var bottom = textArea.scrollTop + textArea.clientHeight >= textArea.scrollHeight; 
       var up = e.pageY > this.lastY; 
       var down = e.pageY < this.lastY; 
       this.lastY = e.pageY; 
       // default (mobile safari) action when dragging past the top or bottom of a scrollable 
       // textarea is to scroll the containing div, so prevent that. 
       if((top && up) || (bottom && down)) e.preventDefault(); 
       // Sencha disables textarea scrolling on iOS by default, 
       // so stop propagating the event to delegate to iOS. 
       if(!(top && bottom)) e.stopPropagation(); 
      } 
     }); 
+0

감사 톤 : 내 응용 프로그램에서

내가, 해결 방법을 사용 TextArea 구성 요소를 무시, 여기에 코드입니다! 그것은 나를 위해 작동합니다. 그런데 텍스트 영역이 집중되지 않고 키보드가 열리지 않을 때 어떻게 스크롤 할 수 있는지 알고 있습니까? –

+0

죄송합니다. 가능한지 모르겠습니다. – mikemm13

관련 문제