Using edit-text widget and the mouse to position the cursor or select text

Folks,

I am using the edit-text widget as follows;

<$edit-text tiddler=tiddlername field=fieldname focus=yes/>
  • This works in a tiddler body, the text is selected and I can use my mouse to position the cursor, select text and ctrl-a to select all again if needed

Now I am building, below is a selective edit non-working sample inside a procedure

<$list filter="[<popup-tiddler>!has[title]]" variable=~>
<$transclude tiddler=<<reference.tiddler>> field=<<reference.field>>/> <<edit-it-button>>
</$list>
<$list filter="[<popup-tiddler>has[title]]" variable=~>
<$edit-text tiddler=<<reference.tiddler>> field=<<reference.field>> focus=yes/> <<view-it-button>>
</$list>

The problem

In this and other cases when I use the edit-text widget something causes the use of the mouse to fail and rather than select or position the cursor the mouse click results in the popup being reversed and the editing stops.

  • I can NOT use my mouse to position the cursor, select text and ctrl-a to select all again if needed
  • As you see from my above code the popup buttons are defined as <<edit-it-button>> and <<view-it-button>> and they are separate from the edit widget.
  • Why would the edit respond as if it was the button being clicked?

Here is the code for my button(s).

   \procedure edit-it-button() <$button tooltip="edit this value" popup=<<popup-tiddler>> class="tc-btn-invisible">{{$:/core/images/edit-button}}</$button>

I would appreciate some advice in this one as it is a persistent problem I come across.

By default, any click inside a popup dismisses the popup. For example, in the tiddler’s “more” menu, clicking on any item (which are $button widgets) automatically closes the popup.

To prevent clicks inside the $edit-text widget from doing this, add class="tc-popup-handle" to the widget, like this:

<$edit-text tiddler=<<reference.tiddler>> field=<<reference.field>> focus=yes class="tc-popup-handle"/> <<view-it-button>>

-e

That is the answer thanks @EricShulman

I notice with focus=yes the content is selected, however if the same edit is displayed elsewhere at the same time it gets confused about which one to focus on. It can then jump to the other position.

  • In this case I had the tiddler open containing this edit, and in a another tiddler it transudes the same tiddler, along with others.
  • I can live without the selection for now, and I am not sure how often it would be an issue.

I am also only now starting to learn about keyboard-driven-input Macro however it is way too complex.

  • in this case I would just like enter to accept and close the edit.

Since the $edit-text widget has tiddler=<<reference.tiddler>> and field=<<reference.field>>, the input is automatically saved to the target as each keystroke occurs. All that remains is to actually close the popup when the enter key is pressed, which you can do using a $keyboard widget , like this:

<$keyboard key="enter" actions="<$action-deletetiddler $tiddler=<<popup-tiddler>>/>">
<$edit-text tiddler=<<reference.tiddler>> field=<<reference.field>> focus=yes class="tc-popup-handle"/> <<view-it-button>>
</$keyboard>

-e

1 Like

Wow @EricShulman

  • I really have neglected this part of tiddlywiki until now.

I never quite new how to make use of the $keyboard as there are not examples, nor the keyboard-driven-input Macro
because of its complexity and many required tiddlers.

Thank you again