1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 19:39:57 +00:00
TiddlyWiki5/editions/dev/tiddlers/from Heigele and Jurke/Messages.tid

23 lines
1.0 KiB
Plaintext
Raw Normal View History

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-12 16:27:58 +00:00
{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]].