aboutsummaryrefslogtreecommitdiff
path: root/gui/PopUpWidget.cpp
diff options
context:
space:
mode:
authorMax Horn2002-12-12 23:31:58 +0000
committerMax Horn2002-12-12 23:31:58 +0000
commitf4d78cd330dcdbb09e049f1349ae3a88016acd11 (patch)
tree3a86dae86eaeb56f3814a1cf489eef728e32377c /gui/PopUpWidget.cpp
parent2af8f203445664819d101a802635b9c37de97af7 (diff)
downloadscummvm-rg350-f4d78cd330dcdbb09e049f1349ae3a88016acd11.tar.gz
scummvm-rg350-f4d78cd330dcdbb09e049f1349ae3a88016acd11.tar.bz2
scummvm-rg350-f4d78cd330dcdbb09e049f1349ae3a88016acd11.zip
added timeout for popup; fixed notifcation sent when popup item is chosen
svn-id: r5920
Diffstat (limited to 'gui/PopUpWidget.cpp')
-rw-r--r--gui/PopUpWidget.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp
index b0a98fb900..dd4a571b7a 100644
--- a/gui/PopUpWidget.cpp
+++ b/gui/PopUpWidget.cpp
@@ -22,6 +22,7 @@
#include "PopUpWidget.h"
#include "dialog.h"
#include "newgui.h"
+#include "common/engine.h"
/* TODO:
* - draw an (unselectable) sepeator line for items that start with a '-'
@@ -52,6 +53,7 @@ protected:
int _clickX, _clickY;
byte *_buffer;
int _selection;
+ uint32 _openTime;
public:
PopUpDialog(PopUpWidget *boss, int clickX, int clickY);
@@ -93,6 +95,9 @@ PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
// Remember original mouse position
_clickX = clickX - _x;
_clickY = clickY - _y;
+
+ // Time the popup was opened
+ _openTime = g_system->get_msecs();
}
void PopUpDialog::drawDialog()
@@ -123,12 +128,13 @@ void PopUpDialog::handleMouseUp(int x, int y, int button, int clickCount)
// Mouse was released. If it wasn't moved much since the original mouse down,
// let the popup stay open. If it did move, assume the user made his selection.
int dist = (_clickX - x) * (_clickX - x) + (_clickY - y) * (_clickY - y);
- if (dist > 3*3) {
+ if (dist > 3*3 || g_system->get_msecs() - _openTime > 300) {
setResult(_selection);
close();
}
_clickX = -1;
_clickY = -1;
+ _openTime = (uint32)-1;
}
void PopUpDialog::handleMouseMoved(int x, int y, int button)
@@ -214,7 +220,7 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount)
int newSel = popupDialog.runModal();
if (newSel != -1 && _selectedItem != newSel) {
_selectedItem = newSel;
- sendCommand(kPopUpItemSelectedCmd, _selectedItem);
+ sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag);
}
}