diff --git a/osx/dialogxml/dialog.cpp b/osx/dialogxml/dialog.cpp index 4fa3befb..d7cc0b10 100644 --- a/osx/dialogxml/dialog.cpp +++ b/osx/dialogxml/dialog.cpp @@ -1060,6 +1060,10 @@ void cDialog::setBg(short n){ bg = n; } +void cDialog::setDefBtn(std::string defBtn) { + defaultButton = defBtn; +} + void cDialog::setDefTextClr(sf::Color clr){ defTextClr = clr; } diff --git a/osx/dialogxml/dialog.h b/osx/dialogxml/dialog.h index bf5391e2..b10646c6 100644 --- a/osx/dialogxml/dialog.h +++ b/osx/dialogxml/dialog.h @@ -55,6 +55,7 @@ public: template void setResult(const type& val); void setBg(short n); void setDefTextClr(sf::Color clr); + void setDefBtn(std::string defBtn); sf::Color getDefTextClr(); bool toast(); cControl& getControl(std::string id); diff --git a/osx/dialogxml/dlogutil.cpp b/osx/dialogxml/dlogutil.cpp index da1f3eaa..8e66d6c2 100644 --- a/osx/dialogxml/dlogutil.cpp +++ b/osx/dialogxml/dlogutil.cpp @@ -297,6 +297,8 @@ void cThreeChoice::init_buttons(cBasicButtonType btn1, cBasicButtonType btn2, cB if(btn2) btns[1] = btn2; if(btn3) btns[2] = btn3; cDialog* me = operator->(); + // TODO: Is it correct for the first button to always be the default? + bool haveDefault = false; for(int i = 0; i < 3; i++){ if(!btns[i]) continue; std::ostringstream sout; @@ -346,6 +348,12 @@ void cThreeChoice::init_buttons(cBasicButtonType btn1, cBasicButtonType btn2, cB } me->add(btn, cur_btn_rect, sout.str()); cur_btn_rect.right = cur_btn_rect.left - 4; + if(!haveDefault) { + me->setDefBtn(sout.str()); + haveDefault = true; + } else if(btns[i]->label == "OK") { + me->setDefBtn(sout.str()); + } } }