diff options
| author | ruki <[email protected]> | 2017-12-29 23:23:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-12-29 14:21:10 +0800 |
| commit | ff8b64effa9882573426f4d81f4b492d1328fba3 (patch) | |
| tree | 243ba68cf5938c0e4ba14ece0b02339d3a2dfa72 | |
| parent | eb3805ec6e4e4ae187d0cd7c9082e6c8558a51ee (diff) | |
remove event register
| -rw-r--r-- | tests/ui/hello.lua | 4 | ||||
| -rw-r--r-- | xmake/core/ui/application.lua | 3 | ||||
| -rw-r--r-- | xmake/core/ui/panel.lua | 11 | ||||
| -rw-r--r-- | xmake/core/ui/view.lua | 17 |
4 files changed, 8 insertions, 27 deletions
diff --git a/tests/ui/hello.lua b/tests/ui/hello.lua index c2fd6162a..223ab8094 100644 --- a/tests/ui/hello.lua +++ b/tests/ui/hello.lua @@ -55,7 +55,9 @@ end -- on event function hello:event_on(e) - view.event_on(self, e) + if view.event_on(self, e) then + return true + end if e.type == event.ev_keyboard then self:statusbar():info():text_set(e.key_name) if e.key_name == "s" then diff --git a/xmake/core/ui/application.lua b/xmake/core/ui/application.lua index ed2908ddc..0354ecb07 100644 --- a/xmake/core/ui/application.lua +++ b/xmake/core/ui/application.lua @@ -62,9 +62,6 @@ function application:init(name) self:insert(self:menubar()) self:insert(self:desktop()) - -- register event type - self:event_register(event.ev_keyboard) - -- trace log:print("<application: %s>: init ok", name) end diff --git a/xmake/core/ui/panel.lua b/xmake/core/ui/panel.lua index c33811bf3..a13c29889 100644 --- a/xmake/core/ui/panel.lua +++ b/xmake/core/ui/panel.lua @@ -50,13 +50,6 @@ function panel:init(name, bounds) self._VIEWS = dlist() end --- exit panel -function panel:exit() - - -- exit view - view.exit(self) -end - -- get all child views function panel:views() return self._VIEWS:items() @@ -251,8 +244,8 @@ function panel:event_on(e) -- send event to all child views for v in self:views() do - if v:event_need(e) then - v:event_on(e) + if v:event_on(e) then + return true end end end diff --git a/xmake/core/ui/view.lua b/xmake/core/ui/view.lua index 80c3c7bd1..d7d11ee06 100644 --- a/xmake/core/ui/view.lua +++ b/xmake/core/ui/view.lua @@ -76,10 +76,6 @@ function view:init(name, bounds) local attrs = object() self._ATTRS = attrs - -- init needed events type - local events = object() - self._EVENTS = events - -- init name self._NAME = name @@ -233,6 +229,9 @@ function view:invalidate() end -- on event (abstract) +-- +-- @return true: done and break dispatching, false/nil: continous to dispatch to other views +-- function view:event_on(e) end @@ -246,16 +245,6 @@ 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 type function view:type() return self._TYPE |
