From 43e82b32f2d812225e6d7ef76efdbf4873efc343 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 31 Aug 2010 09:34:19 +0000 Subject: luaComboBox and luaDB fixes and improvements. --- client/luawidget.cc | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'client/luawidget.cc') diff --git a/client/luawidget.cc b/client/luawidget.cc index 5abc236..86dc2bb 100644 --- a/client/luawidget.cc +++ b/client/luawidget.cc @@ -280,9 +280,39 @@ static int cmb_add_item(lua_State *L) return 0; } +static int cmb_le_value(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox"); + luaL_argcheck(L, wdgu, 1, "combobox expected"); + + ComboBox *cmb = (ComboBox*)wdgu->widget; + lua_pushstring(L, cmb->lineEditValue().toStdString().c_str()); + + return 1; +} + +static int cmb_le_set_value(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox"); + luaL_argcheck(L, wdgu, 1, "combobox expected"); + + const char *val = luaL_checkstring(L, 2); + + ComboBox *cmb = (ComboBox*)wdgu->widget; + cmb->setLineEditValue(val); + + return 0; +} + #define CMBBOX_METHS \ {"clear", cmb_clear},\ - {"addItem", cmb_add_item} + {"addItem", cmb_add_item},\ + {"lineEditValue", cmb_le_value},\ + {"setLineEditValue", cmb_le_set_value} static const struct luaL_Reg wdg_meths[] = { WDG_METHS, {NULL, NULL} }; -- cgit v1.2.3