From 7e89d8dab0b65c711148c1ddd59c8790e6efaf8f Mon Sep 17 00:00:00 2001 From: Kevin Zakka Date: Mon, 3 Oct 2022 04:30:26 -0700 Subject: [PATCH] In `simulate` UI, clear shortcut string for flags with no shortcuts. PiperOrigin-RevId: 478467279 Change-Id: Icc4317d9e35b41871143572275d03adf7e13d956 --- simulate/simulate.cc | 8 +++++++- src/ui/ui_main.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/simulate/simulate.cc b/simulate/simulate.cc index 0459f1db..855a450d 100644 --- a/simulate/simulate.cc +++ b/simulate/simulate.cc @@ -703,7 +703,11 @@ void makerendering(mj::Simulate* sim, int oldstate) { } // set shortcut and data - mju::sprintf_arr(defFlag[0].other, " %s", mjVISSTRING[i][2]); + if (mjVISSTRING[i][2][0]) { + mju::sprintf_arr(defFlag[0].other, " %s", mjVISSTRING[i][2]); + } else { + mju::sprintf_arr(defFlag[0].other, ""); + } defFlag[0].pdata = sim->vopt.flags + i; mjui_add(&sim->ui0, defFlag); } @@ -712,6 +716,8 @@ void makerendering(mj::Simulate* sim, int oldstate) { mju::strcpy_arr(defFlag[0].name, mjRNDSTRING[i][0]); if (mjRNDSTRING[i][2][0]) { mju::sprintf_arr(defFlag[0].other, " %s", mjRNDSTRING[i][2]); + } else { + mju::sprintf_arr(defFlag[0].other, ""); } defFlag[0].pdata = sim->scn.flags + i; mjui_add(&sim->ui0, defFlag); diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index b101bc3f..7c69f780 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -1027,7 +1027,7 @@ static void setcursor(mjrRect r, mjUI* ui, const mjuiState* ins, const mjrContex // parse modifier and shortcut static void parseshortcut(const char* text, int* mod, int* key) { - // cleear + // clear *mod = 0; *key = 0;