lua: Add "focus" property for Dialog widgets (mainly button and entry)

This commit is contained in:
David Capello 2019-01-10 16:20:11 -03:00
parent 3fddf4dfef
commit 74b2423070

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018 David Capello // Copyright (C) 2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -174,6 +174,12 @@ int Dialog_add_widget(lua_State* L, Widget* widget)
if (type == LUA_TSTRING) if (type == LUA_TSTRING)
label = lua_tostring(L, -1); label = lua_tostring(L, -1);
lua_pop(L, 1); lua_pop(L, 1);
// Focus magnet
type = lua_getfield(L, 2, "focus");
if (type != LUA_TNONE && lua_toboolean(L, -1))
widget->setFocusMagnet(true);
lua_pop(L, 1);
} }
if (label || !dlg->hbox) { if (label || !dlg->hbox) {