00001 00002 /* 00003 ----------------------------------------------------------------------------- 00004 This source file is part of OGRE 00005 (Object-oriented Graphics Rendering Engine) 00006 For the latest info, see http://www.ogre3d.org/ 00007 00008 Copyright © 2000-2002 The OGRE Team 00009 Also see acknowledgements in Readme.html 00010 00011 This program is free software you can redistribute it and/or modify it under 00012 the terms of the GNU Lesser General Public License as published by the Free Software 00013 Foundation either version 2 of the License, or (at your option) any later 00014 version. 00015 00016 This program is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS 00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License along with 00021 this program if not, write to the Free Software Foundation, Inc., 59 Temple 00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00023 http://www.gnu.org/copyleft/lesser.txt. 00024 ----------------------------------------------------------------------------- 00025 */ 00026 #include "OgreStableHeaders.h" 00027 00028 #include "OgreKeyEvent.h" 00029 #include "OgreEventListeners.h" 00030 #include "OgreKeyTarget.h" // HACK move higher 00031 #include "OgreEventMulticaster.h" 00032 00033 00034 00035 namespace Ogre { 00036 00037 00038 KeyTarget::KeyTarget() 00039 { 00040 mKeyListener = 0; 00041 } 00042 //----------------------------------------------------------------------- 00043 00044 void KeyTarget::processKeyEvent(KeyEvent* e) 00045 { 00046 KeyListener* listener = mKeyListener; 00047 if (listener != NULL) 00048 { 00049 int id = e->getID(); 00050 switch(id) 00051 { 00052 case KeyEvent::KE_KEY_PRESSED: 00053 listener->keyPressed(e); 00054 break; 00055 case KeyEvent::KE_KEY_RELEASED: 00056 listener->keyReleased(e); 00057 break; 00058 case KeyEvent::KE_KEY_CLICKED: 00059 listener->keyClicked(e); 00060 break; 00061 } 00062 } 00063 } 00064 00065 void KeyTarget::addKeyListener(KeyListener* l) 00066 { 00067 if (l == NULL) 00068 { 00069 return; 00070 } 00071 mKeyListener = EventMulticaster::add(mKeyListener,l); 00072 } 00073 00074 void KeyTarget::removeKeyListener(KeyListener* l) 00075 { 00076 if (l == NULL) 00077 { 00078 return; 00079 } 00080 mKeyListener = EventMulticaster::remove(mKeyListener,l); 00081 } 00082 } 00083
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:14 2004