From 85eaa17d79ce4eb399470a0a20d6dc59f9b07c43 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 18 May 2014 01:57:28 +1000 Subject: Add widget hide, show, and text setting functions. --- lib/skang.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/skang.lua b/lib/skang.lua index 90079ad..e44d4bc 100644 --- a/lib/skang.lua +++ b/lib/skang.lua @@ -1031,14 +1031,18 @@ local widgets = {} --thingasm{widgets, 'window', 'The window.', types='userdata'} thingasm{widgets, 'W', 'Holds all the widgets', types='Keyed'} widgets.W{'Cwidget', 'The widget.', types='userdata'} -widgets.W{'action,a', 'The action for the widget.', 'nada', types='string'} +widgets.W{'action,a', 'The action for the widget.', 'nada()', types='string'} +widgets.W{'text,t', 'The text for the widget.', '', types='string'} local aIsValid = function (self, parent) local result = Thing.isValid(self, parent) if result then local value = parent[self.names[1] ] + if 'userdata' == type(parent.Cwidget) then --print('NEW ACTION - ' .. self.names[1] .. ' = ' .. value .. ' ' .. type(parent.Cwidget)) - action(parent.Cwidget, value) + if ('action' == self.names[1]) and ('nada()' ~= value) then action(parent.Cwidget, value) end + if ('text' == self.names[1]) and ('' ~= value) then text (parent.Cwidget, value) end + end end return result end @@ -1095,6 +1099,8 @@ window = function(w, h, title, name) win = copy(widgets, name) local wMum, wThingy = getStuffed(win.W, 'a') wThingy.isValid = aIsValid + local wMum, wThingy = getStuffed(win.W, 't') + wThingy.isValid = aIsValid win.window = Cwindow(caller, w, h, title, name) return win end -- cgit v1.1