* Register widgetGetTime() as betawidget.getTime() in Lua

* In the Lua test app use betawidget.getTime() to determine the *true* amount of time passed since registering of the timer event


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5979 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-09-09 11:17:38 +00:00
parent 0d3b868de7
commit 9177d9cf2f
2 changed files with 7 additions and 3 deletions

View File

@ -74,6 +74,9 @@ static bool callbackDestructor(widget* const self, const event* const evt, int c
}
%}
%rename (getTime) widgetGetTime;
int widgetGetTime(void);
%rename (getClipboardText) widgetGetClipboardText;
%rename (setClipboardText) widgetSetClipboardText;
%typemap (newfree) char * "free($1);";

View File

@ -1,3 +1,5 @@
-- vim:set et sts=2 sw=2:
wnd = betawidget.window("myWindow", 400, 400)
wnd:reposition(400, 50)
wnd:show()
@ -19,10 +21,9 @@ wnd:addEventHandler(betawidget.EVT_MOUSE_CLICK,
)
wnd:addTimerEventHandler(betawidget.EVT_TIMER_PERSISTENT, 1000,
(function ()
local time = 0
local starttime = betawidget.getTime()
return function (self, evt, handlerId)
time = time + 1
print(string.format("%d seconds passed", time))
print(string.format("%f seconds passed", (betawidget.getTime() - starttime) / 1000))
end
end)()
)