Extend the betawidget Lua testapp:

* Be more interesting when clicking the first window
 * Add a timer event handler
 * Add a clipboard usage example


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5968 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-09-08 00:32:22 +00:00
parent 1eefcb27c9
commit 574a74ab35
1 changed files with 17 additions and 1 deletions

View File

@ -9,7 +9,20 @@ wnd:addEventHandler(betawidget.EVT_MOUSE_CLICK,
return function (self, evt, handlerId)
clicked = clicked + 1
print(string.format("Clicked %d times", clicked))
self:reposition(0, 0)
if (clicked % 2) == 0 then
self:reposition(400, 50)
else
self:reposition(0, 0)
end
end
end)()
)
wnd:addTimerEventHandler(betawidget.EVT_TIMER_PERSISTENT, 1000,
(function ()
local time = 0
return function (self, evt, handlerId)
time = time + 1
print(string.format("%d seconds passed", time))
end
end)()
)
@ -24,3 +37,6 @@ wnd2 = betawidget.window("myOtherWindow", 100, 100)
wnd2:repositionFromAnchor(wnd, betawidget.CENTRE, 0, betawidget.MIDDLE, 0)
print(string.format("It is: %f %f", wnd2.offset.x, wnd2.offset.y))
wnd2:show()
print(string.format("The clipboard's contents are \"%s\"", betawidget.getClipboardText()))
betawidget.setClipboardText("Hello World")