diff options
| author | ruki <[email protected]> | 2017-12-27 22:30:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-12-27 09:02:06 +0800 |
| commit | 5a9bc97b532309a1d13175e5ce4e82a2f430d58e (patch) | |
| tree | d201b1b561cb7dc70fcbd3eed2029a077ecc2367 /xmake/core/ui/button.lua | |
| parent | c2af438912e29dec6f1e8962633f339a6ab2cab7 (diff) | |
add two button to hello
Diffstat (limited to 'xmake/core/ui/button.lua')
| -rw-r--r-- | xmake/core/ui/button.lua | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/xmake/core/ui/button.lua b/xmake/core/ui/button.lua index 95a4b3fcb..fe9a719c7 100644 --- a/xmake/core/ui/button.lua +++ b/xmake/core/ui/button.lua @@ -24,51 +24,17 @@ -- load modules local log = require("ui/log") -local view = require("ui/view") +local label = require("ui/label") local curses = require("ui/curses") -- define module -local button = button or view() +local button = button or label() -- init button function button:init(name, bounds, text) - -- init view - view.init(self, name, bounds) - - -- init text - self._TEXT = text or "" - - -- init color - self:attr_set("color", curses.color_pair("white", "blue")) -end - --- exit button -function button:exit() - view.exit(self) -end - --- draw view -function button:draw() - - -- trace - log:print("%s: draw ..", self) - - -- draw it - local c = self:canvas() - local s = string.sub(self:text(), 1, self:width()) .. string.rep(' ', self:width() - #self:text()) - c:attr(self:attr("color")):move(0, 0):write(s, self:attr("color")) -end - --- get text -function button:text() - return self._TEXT -end - --- set text -function button:text_set(text) - self._TEXT = text or "" - self:invalidate() + -- init label + label.init(self, name, bounds, text) end -- return module |
