Index: code/branches/MouseAPI_FS19/data/levels/MouseAPIExample.oxw
===================================================================
--- code/branches/MouseAPI_FS19/data/levels/MouseAPIExample.oxw	(revision 12263)
+++ code/branches/MouseAPI_FS19/data/levels/MouseAPIExample.oxw	(revision 12271)
@@ -12,7 +12,5 @@
 ?>
 
-<?lua
-  include("templates/spaceshipEscort.oxt")
-?>
+
 
 <Level >
@@ -25,12 +23,16 @@
     skybox       = "Orxonox/Starbox"
   >
-  <camerapositions>
-        <CameraPosition position="0,0,0" lookat="100,0,0" absolute=true drag=true mouselook=true/>
-  </camerapositions>
+  
+   <CameraPosition position="0,0,0" lookat="100,0,0" absolute=true drag=false mouselook=false/>
+  
 
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
-    <SpawnPoint team=0 position="0,0,0" lookat="0,0,0"/>
+    <SpawnPoint team=0 position="0,0,0" lookat="100,0,0"/>
     
-	<MouseAPIExample position="100,0,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 >
+
+<MouseAPIExample position="100,0,0" direction="0,-1,0" collisionType=dynamic mass=100000 friction=0.01 cameraOffset=100>
+			<camerapositions>
+				<CameraPosition position="0,0,0" absolute=true mouselook=false drag=false direction="1,0,0"/>
+			</camerapositions>
 	    <attached> 
 		<Model position="0,0,0" mesh="cube.mesh" scale3D="10,10,10" /> 
@@ -40,5 +42,7 @@
 	    </collisionShapes>
         
-	</MouseAPIExample>
+</MouseAPIExample>
+
+
     
   </Scene>
Index: code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc
===================================================================
--- code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc	(revision 12263)
+++ code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc	(revision 12271)
@@ -1,5 +1,7 @@
 #include "mouseapi.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+namespace orxonox{
 
-namespace orxonox{
+ManageScopedSingleton(MouseAPI, ScopeID::GRAPHICS, false);
 
 MouseAPI::MouseAPI()
@@ -10,4 +12,5 @@
 void MouseAPI::activate()
 {
+    active = true;
      if(InputManager::exists())
      {
@@ -23,4 +26,5 @@
 void MouseAPI::deactivate()
 {
+    active = false;
     if(InputManager::exists())
     {
@@ -29,4 +33,6 @@
         InputManager::getInstance().destroyState("MouseAPI");
     }
+    clickEvents.clear();
+    scrollEvents.clear();
 }
 
@@ -38,5 +44,5 @@
 void MouseAPI::buttonPressed(MouseButtonCode::ByEnum button)
 {
-    cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera();
+    cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera();//todo: trycatch
     Ogre::Viewport *vp = GraphicsManager::getInstance().getViewport();
     Ogre::Ray ray = cam->getCameraToViewportRay(mousePos.x/((float)vp->getActualWidth()),mousePos.y/((float)vp->getActualHeight()));
@@ -57,29 +63,36 @@
 void MouseAPI::mouseScrolled(int abs, int rel)
 {
+    cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera();
     Ogre::Viewport *vp = GraphicsManager::getInstance().getViewport();
     Ogre::Ray ray = cam->getCameraToViewportRay(mousePos.x/((float)vp->getActualWidth()),mousePos.y/((float)vp->getActualHeight()));
     for(auto event:scrollEvents){
         if(!event.considerPosition || ray.intersects(Ogre::Sphere(event.position,event.radius)).first)
-            (*(event.onScrolledFunction))(abs,rel,mousePos);
+            event.onScrolledFunction(abs,rel,mousePos);
     }
 }
 
-void MouseAPI::addClickableObject(const Vector3& position, float radius, const std::list<MouseButtonCode::ByEnum>& buttons, std::function<void(MouseButtonCode::ByEnum)> onClickedFunction)
+ClickableObjectID MouseAPI::addClickableObject(const Vector3& position, float radius, const std::list<MouseButtonCode::ByEnum>& buttons, std::function<void(MouseButtonCode::ByEnum)> onClickedFunction)
 {
-    clickEvents.insert(clickEvents.begin(),{position,radius,buttons,onClickedFunction});
+    clickEvents.insert(clickEvents.begin(),{!clickEvents.empty() ? clickEvents.back().id + 1:0,position,radius,buttons,onClickedFunction});
+    return clickEvents.back().id;
 }
-void MouseAPI::addScrollElement(const Vector3& position,float radius,void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos))
+ScrollableElementID MouseAPI::addScrollElement(const Vector3& position, float radius, std::function<void(int abs,int rel,const IntVector2& mousePos)> onScrolledFunction)
 {
-    scrollEvents.insert(scrollEvents.begin(),{position,radius,onScrolledFunction});
+    scrollEvents.insert(scrollEvents.begin(),{!scrollEvents.empty() ? scrollEvents.back().id + 1:0,position,radius,onScrolledFunction});
+    return scrollEvents.back().id;
 }
-void MouseAPI::addScrollElement(void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos))
+ScrollableElementID MouseAPI::addScrollElement(std::function<void(int abs,int rel,const IntVector2& mousePos)> onScrolledFunction)
 {
-    scrollEvents.insert(scrollEvents.begin(),{onScrolledFunction});
+    scrollEvents.insert(scrollEvents.begin(),{!scrollEvents.empty() ? scrollEvents.back().id + 1:0,onScrolledFunction});
+    return scrollEvents.back().id;
 }
 
-void MouseAPI::changeCamera(Camera& camera)
-{
-    cam = camera.getOgreCamera();
-}
+//todo
+void MouseAPI::changePositionOfClickableObject(ClickableObjectID id,const Vector3& position){}
+void MouseAPI::changePositionOfScrollableElement(ScrollableElementID id,const Vector3& position){}
+void MouseAPI::changeRadiusOfClickableObject(ClickableObjectID id,float radius){}
+void MouseAPI::changeRadiusOfScrollableElement(ScrollableElementID id,float radius){}
+void MouseAPI::deleteClickableObject(ClickableObjectID){}
+void MouseAPI::deleteScrollableElement(ScrollableElementID){}
 
 }
Index: code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h
===================================================================
--- code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h	(revision 12263)
+++ code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h	(revision 12271)
@@ -20,32 +20,39 @@
 {
 
-class MouseAPI : public InputHandler
+typedef uint ClickableObjectID;
+typedef uint ScrollableElementID;
+
+class MouseAPI : public InputHandler, public Singleton<MouseAPI>
 {
-
+friend class Singleton<MouseAPI>;
 private:
 
     struct clickableElement
     {
+        //static ClickableObjectID lastClID;
+        ClickableObjectID id;
         Vector3 position;
         float radius;
         std::list<MouseButtonCode::ByEnum> buttons;
         std::function<void(MouseButtonCode::ByEnum button)> onClickedFunction;
-        clickableElement(const Vector3& position,float radius,const std::list<MouseButtonCode::ByEnum>& buttons,std::function<void(MouseButtonCode::ByEnum button)> onClickedFunction):position(position),
-            radius(radius), buttons(buttons), onClickedFunction(onClickedFunction){}
+        clickableElement(ClickableObjectID id,const Vector3& position,float radius,const std::list<MouseButtonCode::ByEnum>& buttons,std::function<void(MouseButtonCode::ByEnum button)> onClickedFunction):position(position),
+            radius(radius), buttons(buttons), onClickedFunction(onClickedFunction),id(id){}
     };
 
     struct scrollElement
     {
+        static ScrollableElementID lastScID;
+        ScrollableElementID id;
         bool considerPosition;
         Vector3 position;
         float radius;
-        void (*onScrolledFunction)(int abs,int rel,const IntVector2& mousePos);
-        scrollElement(void (*onScrolledFunction)(int abs,int rel,const IntVector2& mousePos)):considerPosition(false),
-            onScrolledFunction(onScrolledFunction){}
-        scrollElement(const Vector3& position, float radius, void (*onScrolledFunction)(int abs,int rel,const IntVector2& mousePos)):considerPosition(true),
-            position(position), radius(radius), onScrolledFunction(onScrolledFunction){}
+        std::function<void(int abs,int rel,const IntVector2& mousePos)> onScrolledFunction;
+        scrollElement(ScrollableElementID id,std::function<void(int abs,int rel,const IntVector2& mousePos)> onScrolledFunction):considerPosition(false),
+            onScrolledFunction(onScrolledFunction),id(id){}
+        scrollElement(ScrollableElementID id,const Vector3& position, float radius, std::function<void(int abs,int rel,const IntVector2& mousePos)> onScrolledFunction):considerPosition(true),
+            position(position), radius(radius), onScrolledFunction(onScrolledFunction),id(id){}
     };
 
-
+    static MouseAPI* singletonPtr_s;
     std::list<clickableElement> clickEvents;
     std::list<scrollElement> scrollEvents;
@@ -53,4 +60,6 @@
     IntVector2 mousePos;
     InputState* state;
+    bool active = false;
+
 
 
@@ -65,11 +74,17 @@
     virtual void mouseScrolled (int abs, int rel) override;
 
-    void addClickableObject(const Vector3& position,float radius,const std::list<MouseButtonCode::ByEnum>& buttons,std::function<void(MouseButtonCode::ByEnum button)>  onClickedFunction);
-    void addScrollElement(const Vector3& position,float radius,void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos));
-    void addScrollElement(void (*onScrolledFunction)(int abs,int rel,const IntVector2&  mousePos));
+    ClickableObjectID addClickableObject(const Vector3& position,float radius,const std::list<MouseButtonCode::ByEnum>& buttons,std::function<void(MouseButtonCode::ByEnum button)>  onClickedFunction);
+    ScrollableElementID addScrollElement(const Vector3& position,float radius,std::function<void(int abs,int rel,const IntVector2& mousePos)> onScrolledFunction);
+    ScrollableElementID addScrollElement(std::function<void(int abs,int rel,const IntVector2& mousePos)> onScrolledFunction);
 
-    void changeCamera(Camera& camera);
+    void changePositionOfClickableObject(ClickableObjectID id,const Vector3& position);
+    void changePositionOfScrollableElement(ScrollableElementID id,const Vector3& position);
+    void changeRadiusOfClickableObject(ClickableObjectID id,float radius);
+    void changeRadiusOfScrollableElement(ScrollableElementID id,float radius);
+    void deleteClickableObject(ClickableObjectID);
+    void deleteScrollableElement(ScrollableElementID);
 
     void activate();
+    static bool isActive(){return singletonPtr_s != nullptr && getInstance().active;}
     void deactivate();
 };
Index: code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.cc
===================================================================
--- code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.cc	(revision 12263)
+++ code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.cc	(revision 12271)
@@ -6,9 +6,8 @@
 RegisterClass(MouseAPIExample);
 
-MouseAPIExample::MouseAPIExample(Context* context) : StaticEntity(context)
+MouseAPIExample::MouseAPIExample(Context* context) : ControllableEntity(context)
 {
     RegisterObject(MouseAPIExample);
-    mouseapi.activate();
-    mouseapi.addClickableObject(getPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left},[this](MouseButtonCode::ByEnum mouse){this->testfunction(mouse);});
+    //mouseapi = MouseAPI::getInstance();
 
 }
@@ -16,5 +15,12 @@
 MouseAPIExample::~MouseAPIExample()
 {
-    mouseapi.deactivate();
+    if(MouseAPI::isActive())
+        MouseAPI::getInstance().deactivate();
+}
+
+void MouseAPIExample::tick(float dt)
+{
+    ControllableEntity::tick(dt);
+
 }
 
@@ -27,4 +33,7 @@
 {
     SUPER(MouseAPIExample, XMLPort, xmlelement, mode);
+    MouseAPI::getInstance().activate();
+    MouseAPI::getInstance().addClickableObject(this->getWorldPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left},[this](MouseButtonCode::ByEnum mouse){this->testfunction(mouse);});
+
 }
 }
Index: code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.h
===================================================================
--- code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.h	(revision 12263)
+++ code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.h	(revision 12271)
@@ -7,10 +7,10 @@
 #include "util/output/OutputManager.h"
 #include "util/output/ConsoleWriter.h"
-#include "worldentities/StaticEntity.h"
+#include "worldentities/ControllableEntity.h"
 #include "core/CoreIncludes.h"
 
 namespace orxonox
 {
-class MouseAPIExample : public StaticEntity
+class MouseAPIExample : public ControllableEntity
 {
 public:
@@ -18,6 +18,6 @@
     ~MouseAPIExample();
     virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-    MouseAPI mouseapi;
     void testfunction(MouseButtonCode::ByEnum mouse);
+    virtual void tick(float dt) override;
 };
 }
