summaryrefslogtreecommitdiff
path: root/tests/ui/desktop.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-07 22:45:25 +0800
committerruki <[email protected]>2020-05-07 10:32:31 +0800
commitca238c29d3e14b0c72787b47588b979356dd9410 (patch)
treeaccec9b30f7b057b9bfbf9cf9e5985d5060232db /tests/ui/desktop.lua
parent5d22635894f2b19f49441e0671ac0eb1b1da9c17 (diff)
update ui
Diffstat (limited to 'tests/ui/desktop.lua')
-rw-r--r--tests/ui/desktop.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/ui/desktop.lua b/tests/ui/desktop.lua
index 6f4cda6aa..cc5881abf 100644
--- a/tests/ui/desktop.lua
+++ b/tests/ui/desktop.lua
@@ -16,7 +16,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file desktop.lua
@@ -49,7 +49,7 @@ function demo:init()
self:menubar():title():text_set("Menu Bar (Hello)")
-- add title label
- self:desktop():insert(label:new("title", rect {0, 0, 12, 1}, "hello xmake!"):textattr_set("white"), {centerx = true})
+ self:desktop():insert(label:new("title", rect {0, 0, 12, 1}, "hello ltui!"):textattr_set("white"), {centerx = true})
-- add yes button
self:desktop():insert(button:new("yes", rect {0, 1, 7, 2}, "< Yes >"):textattr_set("white"), {centerx = true})
@@ -59,8 +59,8 @@ function demo:init()
end
-- on event
-function demo:event_on(e)
- if application.event_on(self, e) then
+function demo:on_event(e)
+ if application.on_event(self, e) then
return true
end
if e.type == event.ev_keyboard then
@@ -75,6 +75,14 @@ function demo:event_on(e)
end
end
+-- on resize
+function demo:on_resize()
+ for v in self:desktop():views() do
+ self:center(v, {centerx = true})
+ end
+ application.on_resize(self)
+end
+
-- main entry
function main(...)
demo:run(...)