1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/widgets/ActionWidgets.tid
Jermolene 3c20f2396e Add support for assigning action widgets via the actions attribute
This is quite a big change: a new way to invoke action widgets.

The advantage is that it solves #2217 and #1564, a long running problem
that prevented us from adding action widgets to widgets that modify the
store.

This commit adds the new technique for the button and keyboard widgets,
but also extends the select widget to trigger action widgets for the
first time
2016-04-29 18:54:44 +01:00

45 lines
1.6 KiB
Plaintext

created: 20141008134425548
modified: 20160429165240169
tags: Widgets
title: ActionWidgets
type: text/vnd.tiddlywiki
Action widgets are a special type of widget that have no visual appearance but perform an action when triggered (such as sending a message, navigating to a tiddler, or changing the value of a tiddler). Action widgets are used in association with other widgets that trigger those actions (for example, the ButtonWidget).
The following action widgets are provided:
<<list-links "[tag[ActionWidgets]]">>
There are two ways to use action widgets:
* Using the `actions` attribute of the triggering widget (this is the preferred way)
* Embedding the actions within the triggering widget (an older technique that is now deprecated)
!! Assigning action widgets with the `actions` attribute
The action widgets are passed as a string to the `actions` attribute of the triggering widget. Usually, it is more convenient to use a macro to assign the action widgets to a variable. For example, here is a button that triggers two actions of sending different messages:
```
\define my-actions()
<$action-sendmessage $message="tm-home"/>
<$action-sendmessage $message="tm-full-screen"/>
\end
<$button actions=<<my-actions>>>
Click me!
</$button>
```
!! Assigning action widgets by embedding
The action widgets need not be immediate children of their triggering widget, but they must be descendents of it. The actions are performed in sequence. Here is the above example rewritten to use embedding:
```
<$button>
<$action-sendmessage $message="tm-home"/>
<$action-sendmessage $message="tm-full-screen"/>
Click me!
</$button>
```