Changeset 7863 in orxonox.OLD for trunk/src/lib
- Timestamp:
- May 25, 2006, 6:02:27 PM (19 years ago)
- Location:
- trunk/src/lib/gui/qt_gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/qt_gui/gui_control.cc
r7862 r7863 30 30 #include <QtCore/QEvent> 31 31 #include <QtGui/QKeyEvent> 32 #include <QtGui/QMouseEvent> 32 33 33 34 #include "sdlincl.h" … … 93 94 Saveable::load(); 94 95 this->setText(QString().fromStdString(this->value().getString())); 95 printf("%s\n", this->value().getString().c_str());96 96 } 97 97 … … 105 105 bool GuiControlInput::event ( QEvent * e ) 106 106 { 107 if (!this->bListening || e->type() != QEvent::KeyPress) 108 return QPushButton::event(e); 109 110 111 this->releaseKeyboard(); 112 this->bListening = true; 113 if (e->type() == QEvent::KeyPress) 107 if (this->bListening && (e->type() == QEvent::KeyPress || e->type() == QEvent::MouseButtonPress)) 114 108 { 115 QKeyEvent* event = dynamic_cast<QKeyEvent*>(e); 116 117 int ev = QtKToSDLK(event->key()); 118 if (ev != -1) 109 this->bListening = false; 110 this->releaseKeyboard(); 111 this->releaseMouse(); 112 /// KEY IS PRESSED: 113 if (e->type() == QEvent::KeyPress) 119 114 { 120 this->setText(QString().fromStdString(SDLKToKeyname(ev))); 115 QKeyEvent* event = dynamic_cast<QKeyEvent*>(e); 116 117 int ev = QtKToSDLK(event->key()); 118 if (ev != -1) 119 { 120 this->setText(QString().fromStdString(SDLKToKeyname(ev))); 121 } 122 return true; 121 123 } 124 /// MOUSE BUTTON PRESSED: 125 if (e->type() == QEvent::MouseButtonPress) 126 { 127 QMouseEvent* event = dynamic_cast<QMouseEvent*>(e); 128 if (event->button() != Qt::NoButton) 129 { 130 this->setText(QString().fromStdString(QtKToString(event->button()))); 131 } 132 133 } 134 122 135 } 123 return true; 136 137 return QPushButton::event(e); 124 138 } 125 139 … … 128 142 this->bListening = true; 129 143 this->grabKeyboard(); 144 this->grabMouse(); 130 145 } 131 146 … … 271 286 } 272 287 } 288 289 std::string GuiControlInput::QtKToString(int button) 290 { 291 if( button == Qt::LeftButton) return "BUTTON_LEFT"; 292 if( button == Qt::MidButton) return "BUTTON_MIDDLE"; 293 if( button == Qt::RightButton) return "BUTTON_RIGHT"; 294 //if( button == Qt::) return "BUTTON_WHEELUP"; 295 //if( button == EV_MOUSE_BUTTON_WHEELDOWN) return "BUTTON_WHEELDOWN"; 296 return "UNKNOWN"; 297 } 298 273 299 } -
trunk/src/lib/gui/qt_gui/gui_control.h
r7862 r7863 38 38 39 39 static int QtKToSDLK(int key); 40 static std::string QtKToString(int button); 40 41 41 42 public slots:
Note: See TracChangeset
for help on using the changeset viewer.