From 39670a73c04e3e35b4c68d98ec4956ba7ed9710c Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 27 Jul 2002 14:16:14 +0000 Subject: heaps of changes to NewGUI: mouseDown/Up events now count the clicks (so you can detect double/triple clicks); ListWidget sends a message if an item was double clicked or changed; you can abort editing in the ListWidget by pressing ESC; SaveLoadDialog will save when you double click and item, and when you finish editing an item by pressing return, will save svn-id: r4656 --- gui/dialog.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'gui/dialog.cpp') diff --git a/gui/dialog.cpp b/gui/dialog.cpp index c4f53892c7..a6bb965f98 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -93,7 +93,7 @@ void Dialog::draw() } } -void Dialog::handleMouseDown(int x, int y, int button) +void Dialog::handleMouseDown(int x, int y, int button, int clickCount) { Widget *w; w = findWidget(x, y); @@ -112,10 +112,10 @@ void Dialog::handleMouseDown(int x, int y, int button) } if (_focusedWidget) - _focusedWidget->handleMouseDown(x - _focusedWidget->_x, y - _focusedWidget->_y, button); + _focusedWidget->handleMouseDown(x - _focusedWidget->_x, y - _focusedWidget->_y, button, clickCount); } -void Dialog::handleMouseUp(int x, int y, int button) +void Dialog::handleMouseUp(int x, int y, int button, int clickCount) { Widget *w; @@ -133,17 +133,14 @@ void Dialog::handleMouseUp(int x, int y, int button) } if (w) - w->handleMouseUp(x - w->_x, y - w->_y, button); + w->handleMouseUp(x - w->_x, y - w->_y, button, clickCount); } void Dialog::handleKeyDown(char key, int modifiers) { - // ESC closes all dialogs by default - if (key == 27) - close(); - if (_focusedWidget) { - _focusedWidget->handleKeyDown(key, modifiers); + if (_focusedWidget->handleKeyDown(key, modifiers)) + return; } else { // Hotkey handling Widget *w = _firstWidget; @@ -152,13 +149,17 @@ void Dialog::handleKeyDown(char key, int modifiers) if (w->_type == kButtonWidget && key == toupper(((ButtonWidget *)w)->_hotkey)) { // We first send a mouseDown then a mouseUp. // FIXME: insert a brief delay between both. - w->handleMouseDown(0, 0, 1); - w->handleMouseUp(0, 0, 1); - break; + w->handleMouseDown(0, 0, 1, 1); + w->handleMouseUp(0, 0, 1, 1); + return; } w = w->_next; } } + + // ESC closes all dialogs by default + if (key == 27) + close(); } void Dialog::handleKeyUp(char key, int modifiers) @@ -303,6 +304,7 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui) void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { + case kListItemChangedCmd: case kSaveCmd: if (_savegameList->getSelected() > 0 && !_savegameList->getSelectedString().isEmpty()) { Scumm *s = _gui->getScumm(); @@ -313,6 +315,7 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat close(); } break; + case kListItemDoubleClickedCmd: case kLoadCmd: if (_savegameList->getSelected() > 0 && !_savegameList->getSelectedString().isEmpty()) { Scumm *s = _gui->getScumm(); -- cgit v1.2.3