Changeset 6916 for code/branches/chat2
- Timestamp:
- May 17, 2010, 3:50:30 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/chat2/src/orxonox/ChatInputHandler.cc
r6910 r6916 69 69 configureInputBuffer(); 70 70 71 this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic ); 71 this->inputState = InputManager::getInstance().createInputState( 72 "chatinput", false, false, InputStatePriority::Dynamic ); 72 73 this->inputState->setKeyHandler(this->inpbuf); 73 74 } … … 80 81 81 82 /* add a line */ 82 this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\r', false); 83 this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\n', false); 83 this->inpbuf->registerListener(this, &ChatInputHandler::addline, 84 '\r', false); 85 this->inpbuf->registerListener(this, &ChatInputHandler::addline, 86 '\n', false); 84 87 85 88 /* backspace */ 86 this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\b', true); 87 //this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\177', true); 89 this->inpbuf->registerListener(this, &ChatInputHandler::backspace, 90 '\b', true); 91 92 /* NOTE this doesn't work on my debian linux box, it makes backspace get 93 * registered also when delete is pressed 94 */ 95 //this->inpbuf->registerListener(this, &ChatInputHandler::backspace, 96 //'\177', true); 88 97 89 98 /* exit the chatinputhandler thingy (tbd) */ 90 this->inpbuf->registerListener(this, &ChatInputHandler::exit, '\033', true); // escape 99 this->inpbuf->registerListener(this, &ChatInputHandler::exit, 100 '\033', true); // escape 91 101 92 102 /* delete character */ 93 this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, KeyCode::Delete); 103 this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, 104 KeyCode::Delete); 94 105 95 106 /* cursor movement */ 96 this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight, KeyCode::Right); 97 this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft, KeyCode::Left); 98 this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd, KeyCode::End); 99 this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome, KeyCode::Home); 107 this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight, 108 KeyCode::Right); 109 this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft, 110 KeyCode::Left); 111 this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd, 112 KeyCode::End); 113 this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome, 114 KeyCode::Home); 100 115 101 116 /* GET WINDOW POINTERS */ 102 input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" ); 103 inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" ); 117 input = CEGUI::WindowManager::getSingleton().getWindow( 118 "orxonox/ChatBox/input" ); 119 inputonly = CEGUI::WindowManager::getSingleton().getWindow( 120 "orxonox/ChatBox-inputonly/input" ); 104 121 105 122 /* get pointer to the history window */ 106 CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" ); 123 CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( 124 "orxonox/ChatBox/history" ); 107 125 108 126 /* cast it to a listbox */ … … 171 189 CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text ); 172 190 this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 173 this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 191 this->lb_history->ensureItemIsVisible( 192 dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 174 193 175 194 /* f) make sure the history handles it */ … … 214 233 std::string assembled = "$ " + left + "|" + right; 215 234 235 /* decide what to do based on the active view */ 216 236 if( this->fullchat ) 217 237 { 218 238 /* adjust curser position - magic number 5 for font width */ 219 sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6), 220 cursorpos, assembled.length() ); 239 sub_adjust_dispoffset( 240 (this->input->getUnclippedInnerRect().getWidth()/6), cursorpos, 241 assembled.length() ); 221 242 this->input->setProperty( "Text", assembled.substr( disp_offset ) ); 222 243 } … … 224 245 { 225 246 /* adjust curser position - magic number 5 for font width */ 226 sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6), 227 cursorpos, assembled.length() ); 247 sub_adjust_dispoffset( 248 (this->inputonly->getUnclippedInnerRect().getWidth()/6), cursorpos, 249 assembled.length() ); 228 250 this->inputonly->setProperty( "Text", assembled.substr( disp_offset) ); 229 251 } … … 239 261 std::string msgtosend = this->inpbuf->get(); 240 262 263 /* if someone pressed return and nothing was put in, 264 * just close the window 265 */ 241 266 if( msgtosend.length() == 0 ) 242 267 { this->deactivate();
Note: See TracChangeset
for help on using the changeset viewer.