mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-27 01:35:40 -05:00
Input adapters initialization and disposing
This commit is contained in:
parent
895e662bd5
commit
51e8435b2d
6 changed files with 49 additions and 3 deletions
|
@ -91,10 +91,11 @@ package org.gestouch.core
|
|||
_inputAdapters.push(inputAdapter);
|
||||
inputAdapter.touchesManager = _touchesManager;
|
||||
inputAdapter.gesturesManager = this;
|
||||
inputAdapter.init();
|
||||
}
|
||||
|
||||
|
||||
public function removeInputAdapter(inputAdapter:IInputAdapter):void
|
||||
public function removeInputAdapter(inputAdapter:IInputAdapter, dispose:Boolean = true):void
|
||||
{
|
||||
if (!inputAdapter)
|
||||
{
|
||||
|
@ -107,6 +108,10 @@ package org.gestouch.core
|
|||
}
|
||||
|
||||
_inputAdapters.splice(index, 1);
|
||||
if (dispose)
|
||||
{
|
||||
inputAdapter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@ package org.gestouch.core
|
|||
public interface IGesturesManager
|
||||
{
|
||||
function addInputAdapter(inputAdapter:IInputAdapter):void;
|
||||
function removeInputAdapter(inputAdapter:IInputAdapter):void;
|
||||
function removeInputAdapter(inputAdapter:IInputAdapter, dispose:Boolean = true):void;
|
||||
}
|
||||
}
|
|
@ -7,5 +7,8 @@ package org.gestouch.core
|
|||
{
|
||||
function set touchesManager(value:ITouchesManager):void;
|
||||
function set gesturesManager(value:IGesturesManager):void;
|
||||
|
||||
function init():void;
|
||||
function dispose():void;
|
||||
}
|
||||
}
|
|
@ -33,5 +33,19 @@ package org.gestouch.input
|
|||
{
|
||||
_gesturesManager = value;
|
||||
}
|
||||
|
||||
|
||||
[Abstract]
|
||||
public function init():void
|
||||
{
|
||||
throw new Error("This is abstract method.");
|
||||
}
|
||||
|
||||
|
||||
[Abstract]
|
||||
public function dispose():void
|
||||
{
|
||||
throw new Error("This is abstract method.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,6 +35,19 @@ package org.gestouch.input
|
|||
}
|
||||
|
||||
|
||||
override public function init():void
|
||||
{
|
||||
_stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, true);
|
||||
}
|
||||
|
||||
|
||||
override public function dispose():void
|
||||
{
|
||||
_stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, true);
|
||||
uninstallStageListeners();
|
||||
}
|
||||
|
||||
|
||||
protected function installStageListeners():void
|
||||
{
|
||||
// Maximum priority to prevent event hijacking
|
||||
|
|
|
@ -35,8 +35,19 @@ package org.gestouch.input
|
|||
}
|
||||
|
||||
_stage = stage;
|
||||
}
|
||||
|
||||
|
||||
stage.addEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler, true);
|
||||
override public function init():void
|
||||
{
|
||||
_stage.addEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler, true);
|
||||
}
|
||||
|
||||
|
||||
override public function dispose():void
|
||||
{
|
||||
_stage.removeEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler, true);
|
||||
uninstallStageListeners();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue