From a1fd7bd508a72563ac2b237da7bf538f01a0111a Mon Sep 17 00:00:00 2001 From: "wrenczes@gmail.com" Date: Wed, 22 Jun 2011 05:06:54 +0000 Subject: [PATCH] Added a simple hack so that '1 Player' will show up as the default selection for the Play menu instead of the last item in the list - in my case, the Test Suite. --- projects/mtg/src/SimpleMenu.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 2584b9f79..038672427 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -225,6 +225,17 @@ void SimpleMenu::Add(int id, const char * text, string desc, bool forceFocus) { SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + kVerticalMargin + mCount * kLineHeight, (mCount == 0), autoTranslate); + + // stupid hack, forced out of necessity - since we poll for key events, mouse movements show up as JGE_BTN_NONE events; + // consequently, even though we're setting the hasFocus variable to true for the first item, this gets ignored as a mouse event + // will come through wherever the click occurred, and will change the default selection. To combat this, if we're setting hasFocus, + // change the x/y coords of the click system to point to that selection. This was primarily for fixing the issue where the Play + // menu comes up with the last option selected instead of '1 Player'. + if (mCount == 0) + { + mEngine->LeftClicked(static_cast(mX), static_cast(mY)); + } + smi->desc = desc; JGuiController::Add(smi); if (mCount <= maxItems) mHeight += kLineHeight;