diff options
| author | ruki <[email protected]> | 2017-12-20 23:20:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-12-20 14:04:19 +0800 |
| commit | bf0ea773b29ca4a85430dcb5ab024ed27a8eeb0c (patch) | |
| tree | f21820ed08d80213c1049b50e1b99b07bc19f627 /xmake/core/ui/view.lua | |
| parent | 5924ef4adbe4b084c465bc9604254be60d147074 (diff) | |
fix on event for ui
Diffstat (limited to 'xmake/core/ui/view.lua')
| -rw-r--r-- | xmake/core/ui/view.lua | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/xmake/core/ui/view.lua b/xmake/core/ui/view.lua index 6efb3c525..5c32f59e2 100644 --- a/xmake/core/ui/view.lua +++ b/xmake/core/ui/view.lua @@ -40,13 +40,13 @@ local view = view or object() local screen_lock = 0 -- new view instance -function view:new(name, bounds) +function view:new(name, bounds, ...) -- create instance self = self() -- init view - self:init(name, bounds) + self:init(name, bounds, ...) -- done return self @@ -61,23 +61,16 @@ function view:init(name, bounds) -- init state local state = object() state.visible = false -- view visibility - state.cursor_visible = false -- cursor visibility - state.block_cursor = false -- block cursor state.selected = false -- current selected window inside group state.focused = false -- true if parent is also focused - state.disabled = false -- view disabled - state.modal = false -- is modal view? self._STATE = state -- init options local options = object() options.selectable = false -- true if window can be selected options.top_select = false -- if true, selecting window will bring it to front - options.pre_event = false -- receive event before focused window - options.post_event = false -- receive event after focused window options.centerx = false -- center horizontaly when inserting in parent options.centery = false -- center verticaly when inserting in parent - options.validate = false -- validate self._OPTIONS = options -- init attributes @@ -85,6 +78,10 @@ function view:init(name, bounds) attrs.color = curses.color_pair("blue", "white") self._ATTRS = attrs + -- init needed events type + local events = object() + self._EVENTS = events + -- init name self._NAME = name @@ -228,8 +225,8 @@ function view:show(visible) end end --- do event (abstract) -function view:do_event(e) +-- on event (abstract) +function view:event_on(e) end -- get the current event @@ -242,6 +239,16 @@ function view:event_put(e) return self:parent() and self:parent():event_put(e) end +-- need this event? +function view:event_need(e) + return self._EVENTS[e.type] +end + +-- register an event type +function view:event_register(etype) + self._EVENTS[etype] = true +end + -- get state function view:state(name) return self._STATE[name] |
