diff options
-rw-r--r-- | graphics/macgui/macmenu.cpp | 32 | ||||
-rw-r--r-- | graphics/macgui/macmenu.h | 1 |
2 files changed, 27 insertions, 6 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 42f1d32f58..a6788007ed 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -1042,6 +1042,22 @@ bool MacMenu::mouseMove(int x, int y) { return false; } +bool MacMenu::checkCallback(bool unicode) { + if (unicode) { + if (_unicodeccallback == nullptr) { + warning("MacMenu: no Unicode callback set"); + return false; + } + } else { + if (_ccallback == nullptr) { + warning("MacMenu: no callback set"); + return false; + } + } + + return true; +} + bool MacMenu::mouseRelease(int x, int y) { if (_menuActivated) { _menuActivated = false; @@ -1056,11 +1072,13 @@ bool MacMenu::mouseRelease(int x, int y) { if (_activeItem != -1 && _activeSubItem != -1 && _menustack.back()->items[_activeSubItem]->enabled) { if (_menustack.back()->items[_activeSubItem]->unicode) { - (*_unicodeccallback)(_menustack.back()->items[_activeSubItem]->action, - _menustack.back()->items[_activeSubItem]->unicodeText, _cdata); + if (checkCallback(true)) + (*_unicodeccallback)(_menustack.back()->items[_activeSubItem]->action, + _menustack.back()->items[_activeSubItem]->unicodeText, _cdata); } else { - (*_ccallback)(_menustack.back()->items[_activeSubItem]->action, - _menustack.back()->items[_activeSubItem]->text, _cdata); + if (checkCallback()) + (*_ccallback)(_menustack.back()->items[_activeSubItem]->action, + _menustack.back()->items[_activeSubItem]->text, _cdata); } } @@ -1085,9 +1103,11 @@ bool MacMenu::processMenuShortCut(byte flags, uint16 ascii) { for (uint j = 0; j < _items[i]->submenu->items.size(); j++) if (_items[i]->submenu->items[j]->enabled && tolower(_items[i]->submenu->items[j]->shortcut) == ascii) { if (_items[i]->submenu->items[j]->unicode) { - (*_unicodeccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->unicodeText, _cdata); + if (checkCallback(true)) + (*_unicodeccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->unicodeText, _cdata); } else { - (*_ccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->text, _cdata); + if (checkCallback()) + (*_ccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->text, _cdata); } return true; } diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h index e7c172c3fb..88f6e9bb74 100644 --- a/graphics/macgui/macmenu.h +++ b/graphics/macgui/macmenu.h @@ -92,6 +92,7 @@ private: ManagedSurface _tempSurface; private: + bool checkCallback(bool unicode = false); const Font *getMenuFont(); const Common::String getAcceleratorString(MacMenuItem *item, const char *prefix); void processTabs(); |