diff options
-rw-r--r-- | gui/ListWidget.cpp | 14 | ||||
-rw-r--r-- | gui/ListWidget.h | 2 | ||||
-rw-r--r-- | newgui.cpp | 28 | ||||
-rw-r--r-- | newgui.h | 5 | ||||
-rw-r--r-- | readme.txt | 1 |
5 files changed, 47 insertions, 3 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 68d4817d04..612c8e4d32 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -47,6 +47,7 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h) _selectedItem = -1; _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kScrollBarWidth, _h); _scrollBar->setTarget(this); + _currentKeyDown = 0; // FIXME: This flag should come from widget definition _editable = true; @@ -138,8 +139,10 @@ void ListWidget::handleKeyDown(char key, int modifiers) case '\n': // enter case '\r': if (_selectedItem >= 0) { - _editMode = true; - dirty = true; + if ((_currentKeyDown != '\n' && _currentKeyDown != '\r')) { // override continuous enter keydown + _editMode = true; + dirty = true; + } } break; case 17: // up arrow @@ -183,6 +186,13 @@ void ListWidget::handleKeyDown(char key, int modifiers) _scrollBar->draw(); } + _currentKeyDown = key; +} + +void ListWidget::handleKeyUp(char key, int modifiers) +{ + if (key == _currentKeyDown) + _currentKeyDown = 0; } void ListWidget::lostFocusWidget() diff --git a/gui/ListWidget.h b/gui/ListWidget.h index 5927d44492..0fcee722ec 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -43,6 +43,7 @@ protected: int _entriesPerPage; int _selectedItem; ScrollBarWidget *_scrollBar; + int _currentKeyDown; public: ListWidget(Dialog *boss, int x, int y, int w, int h); virtual ~ListWidget(); @@ -54,6 +55,7 @@ public: virtual void handleMouseDown(int x, int y, int button); virtual void handleKeyDown(char key, int modifiers); + virtual void handleKeyUp(char key, int modifiers); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); protected: diff --git a/newgui.cpp b/newgui.cpp index e03829b3f9..9b0ac54662 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -39,7 +39,8 @@ NewGui::NewGui(Scumm *s) : _s(s), _use_alpha_blending(true), _need_redraw(false),_prepare_for_gui(true), - _pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0) + _pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0), + _currentKeyDown(0) { } @@ -115,9 +116,18 @@ void NewGui::loop() switch(t.event_code) { case OSystem::EVENT_KEYDOWN: activeDialog->handleKeyDown(t.kbd.ascii, t.kbd.flags); + + // init continuous event stream + _currentKeyDown = t.kbd.ascii; + _currentKeyDownFlags = t.kbd.flags; + _eventFiredCount = 1; + _loopCount = 0; break; case OSystem::EVENT_KEYUP: activeDialog->handleKeyUp(t.kbd.ascii, t.kbd.flags); + if (t.kbd.ascii == _currentKeyDown) + // only stop firing events if it's the current key + _currentKeyDown = 0; break; case OSystem::EVENT_MOUSEMOVE: activeDialog->handleMouseMoved(t.mouse.x - activeDialog->_x, t.mouse.y - activeDialog->_y, 0); @@ -137,6 +147,22 @@ void NewGui::loop() _eventList.clear(); } + // check if event should be sent again (keydown) + if (_currentKeyDown != 0) + { + // if only fired once, wait longer + if ( _loopCount >= ((_eventFiredCount > 1) ? 2 : 4) ) + // ^ loops to wait first event + // ^ loops to wait after first event + { + // fire event + activeDialog->handleKeyDown(_currentKeyDown, _currentKeyDownFlags); + _eventFiredCount++; + _loopCount = 0; + } + _loopCount++; + } + _s->drawDirtyScreenParts(); } @@ -82,6 +82,11 @@ protected: Dialog *_aboutDialog; Dialog *_optionsDialog; + // for continuous events (keyDown) + int _currentKeyDown, _currentKeyDownFlags; + int _loopCount; + int _eventFiredCount; + // sound state bool _old_soundsPaused; diff --git a/readme.txt b/readme.txt index 5642fec020..14b2d0c7fc 100644 --- a/readme.txt +++ b/readme.txt @@ -535,6 +535,7 @@ Credits: Felix Jakschitsc - His hard work on Zak256 Andre Souza - SDL-based OpenGL renderer Kovacs Endre Janos - Several fixes for Simon1 + Ralph Brorsen - Helped write the new GUI And to all the contributors, users, and beta testers we've missed. Thanks! |