[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
example[spec] Add a listener to a widget
" self is a coordinator "
| jsObject js widgets tasks listeners newHandler tasksSpec tasksWidget |
newHandler := [ Transcript show: 'OK!'].
jsObject := self template basicAt: #spec.
js := JS @ jsObject.
widgets := (JS @ (js @ #configuration)) @ #widgets.
tasksSpec := (JS @ widgets) @ #tasks.
listeners := (JS @ ((JS @ tasksSpec) @ #configuration)) @ #listeners.
" install a new listener on #tasks widget "
(JS @ listeners) handleAt: #testingEvent put: newHandler.
" self is a coordinator "
tasksWidget := self widgetAt: #tasks.
" trigger event "
tasksWidget triggerEvent: #testingEvent