I was also looking for a similar solution as I am trying to get rid of a bunch of custom code in my project. After banging around on it for about a day, I have come up with a slight hack that doesn’t depend on any custom coding.
Modal Focus
In short:
-
$action-sendmessage will emit any string as a message.
- Place this within a triggering element like
$button set to emit a custom message.
- Wrap the button with a
$messagecatcher that will listen for this custom message which will then fire off a tm-focus-selector message that targets your $edit-text class.
Tiddler to Launch Modal
\define actions()
<$action-sendmessage $message="tm-focus-selector" $param=".my-class"/>
\end
<$messagecatcher $tm-custom=<<actions>>>
<$button>
Show Modal
<$action-sendmessage $message="tm-modal" $param="ModalFocus-modal"/>
<$action-sendmessage $message="tm-custom"/>
</$button>
</$messagecatcher>
Modal Tiddler
<$edit-text tag="input" tiddler=<<currentTiddler>> field="my-field" class="my-class"/>