backport from MainUI C++ Ref: https://github.com/FWGS/mainui_cpp/commit/fad4805fabba6cc6075a768636ebdf49ed4ff058