1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
local sys = require 'lx.sys'
local sysdef= require 'lx.sysdef'
local ioctl = require 'lx.ioctl'
local draw = require 'lx.draw'
local gui = require 'lx.gui'
local mainloop = require 'lx.mainloop'
print("Hello, world!")
gui.open()
gui.load_cursor('sys:/cursors/left_ptr.png')
for x = 0, 255, 16 do
for y = 0, 255, 16 do
gui.surface:fillrect(x, y, 16, 16, gui.surface:rgb(x, y, 0))
end
end
gui.show_cursor()
local fnt = draw.load_font('sys:/fonts/default.bf')
local txt_x, txt_y = 0, 0
gui.on_mouse_down = function (lb, rb, mb)
if lb then
gui.hide_cursor()
gui.surface:write(gui.mouse_x, gui.mouse_y, string.format("Click at %d, %d", gui.mouse_x, gui.mouse_y), fnt, gui.surface:rgb(0, 0, 255))
txt_x = gui.mouse_x
txt_y = gui.mouse_y + fnt:text_height(" ")
gui.show_cursor()
end
end
gui.on_text_input = function(chr)
gui.hide_cursor()
gui.surface:write(txt_x, txt_y, chr, fnt, gui.surface:rgb(0, 0, 255))
txt_x = txt_x + fnt:text_width(chr)
gui.show_cursor()
end
mainloop.run()
os.exit()
|