1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 20:35:17 +03:00

[Lua] popupConfirmation function added

This commit is contained in:
Bertrand Songis 2016-11-05 12:47:34 +01:00
parent 6b5d2039dc
commit 19789c115c

View file

@ -889,6 +889,38 @@ static int luaPopupWarning(lua_State * L)
return 1;
}
/*luadoc
@function popupConfirmation(title, event)
Raises a pop-up on screen that asks for confirmation
@param title (string) text to display
@param event (number) the event variable that is passed in from the
Run function (key pressed)
@retval "CANCEL" user pushed EXIT key
@notice Use only from stand-alone and telemetry scripts.
@status current Introduced in 2.2.0
*/
static int luaPopupConfirmation(lua_State * L)
{
event_t event = luaL_checkinteger(L, 2);
warningText = luaL_checkstring(L, 1);
warningType = WARNING_TYPE_CONFIRM;
runPopupWarning(event);
if (!warningText) {
lua_pushstring(L, warningResult ? "OK" : "CANCEL");
}
else {
warningText = NULL;
lua_pushnil(L);
}
return 1;
}
/*luadoc
@function defaultStick(channel)
@ -1016,6 +1048,7 @@ const luaL_Reg opentxLib[] = {
{ "playHaptic", luaPlayHaptic },
{ "popupInput", luaPopupInput },
{ "popupWarning", luaPopupWarning },
{ "popupConfirmation", luaPopupConfirmation },
{ "defaultStick", luaDefaultStick },
{ "defaultChannel", luaDefaultChannel },
{ "getRSSI", luaGetRSSI },