mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
[lua] Add missing Dialog onchange and onrelease events
Adding the following events: Dialog:entry { onchange } Dialog:number { onchange } Dialog:slider { onchange, onrelease } Dialog:combobox { onchange }
This commit is contained in:
parent
2418a075ca
commit
1311173d97
@ -502,6 +502,19 @@ int Dialog_entry(lua_State* L)
|
||||
}
|
||||
|
||||
auto widget = new ui::Entry(4096, text.c_str());
|
||||
|
||||
if (lua_istable(L, 2)) {
|
||||
int type = lua_getfield(L, 2, "onchange");
|
||||
if (type == LUA_TFUNCTION) {
|
||||
Dialog_connect_signal(
|
||||
L, 1, widget->Change,
|
||||
[](lua_State* L){
|
||||
// Do nothing
|
||||
});
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return Dialog_add_widget(L, widget);
|
||||
}
|
||||
|
||||
@ -522,6 +535,16 @@ int Dialog_number(lua_State* L)
|
||||
widget->setDecimals(lua_tointegerx(L, -1, nullptr));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
type = lua_getfield(L, 2, "onchange");
|
||||
if (type == LUA_TFUNCTION) {
|
||||
Dialog_connect_signal(
|
||||
L, 1, widget->Change,
|
||||
[](lua_State* L){
|
||||
// Do nothing
|
||||
});
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return Dialog_add_widget(L, widget);
|
||||
@ -554,6 +577,29 @@ int Dialog_slider(lua_State* L)
|
||||
}
|
||||
|
||||
auto widget = new ui::Slider(min, max, value);
|
||||
|
||||
if (lua_istable(L, 2)) {
|
||||
int type = lua_getfield(L, 2, "onchange");
|
||||
if (type == LUA_TFUNCTION) {
|
||||
Dialog_connect_signal(
|
||||
L, 1, widget->Change,
|
||||
[](lua_State* L){
|
||||
// Do nothing
|
||||
});
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
type = lua_getfield(L, 2, "onrelease");
|
||||
if (type == LUA_TFUNCTION) {
|
||||
Dialog_connect_signal(
|
||||
L, 1, widget->SliderReleased,
|
||||
[](lua_State* L){
|
||||
// Do nothing
|
||||
});
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return Dialog_add_widget(L, widget);
|
||||
}
|
||||
|
||||
@ -582,6 +628,16 @@ int Dialog_combobox(lua_State* L)
|
||||
}
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
type = lua_getfield(L, 2, "onchange");
|
||||
if (type == LUA_TFUNCTION) {
|
||||
Dialog_connect_signal(
|
||||
L, 1, widget->Change,
|
||||
[](lua_State* L){
|
||||
// Do nothing
|
||||
});
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return Dialog_add_widget(L, widget);
|
||||
|
Loading…
x
Reference in New Issue
Block a user