1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 02:27:19 +00:00
TiddlyWiki5/editions/dev/tiddlers/from Heigele and Jurke/Messages.tid
2014-11-28 10:06:17 +00:00

23 lines
1.0 KiB
Plaintext

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.
Each message has a type property like "tm-delete-tiddler" and a parameter.
```js
{type: "tm-delete-tiddler", param: "MyOldTiddler"}
```
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]].