2014-09-10 15:53:32 +00:00
|
|
|
chapter.of: Widgets
|
|
|
|
created: 20140715080302422
|
|
|
|
modified: 20140717181635787
|
|
|
|
sub.num: 1
|
|
|
|
tags: doc
|
|
|
|
title: Messages
|
|
|
|
|
|
|
|
Messages are events that are triggered by the user. They are generated by widgets for example when the user clicks on a ~ButtonWidget.
|
2014-09-12 16:27:58 +00:00
|
|
|
Each message has a type property like "tm-delete-tiddler" and a parameter.
|
2014-09-10 15:53:32 +00:00
|
|
|
|
|
|
|
```
|
2014-09-12 16:27:58 +00:00
|
|
|
{type: "tm-delete-tiddler", param: "MyOldTiddler"}
|
2014-09-10 15:53:32 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
When such a message is created by a widget it sends the message to it's parent widget which sends it to it's own parent widget and so on.
|
|
|
|
On this way each widget can try to dispatch the message.
|
|
|
|
This concept is realised in the base widget object.
|
|
|
|
It provides a function ``dispatchEvent(message)`` which is called by the children to bubble the message up the widget tree.
|
|
|
|
Another function ``addEventListener(type,listener)`` can be used to bind a function to a specific message type.
|
|
|
|
If the listener returns false, the message is send to the parent widget.
|
|
|
|
|
|
|
|
The TiddlyWiki core plug-in handles a lot of messages in the [[NavigatorWidget|RootWidget and Rendering Startup]].
|