create a text field in a tiddler

63 views
Skip to first unread message

Robert Mark Bram

unread,
May 12, 2008, 5:06:51 AM5/12/08
to TiddlyWiki
Hi All,

One thing I am using a tiddler for is show information that I will
frequently copy and paste into some other place. I am already using
the ReplaceDoubleClick plugin so that I can double click to select
single words without opening up the tiddler for edit, but now I have
values with multiple words. I would like to be able to tab into them
and select all, as I would with a text field. I can put text fields
into a tiddler like this:

<html><input type=text value="some value to c&p"/></html>

As usual though, I would like to find a shorter way. Is there a
shorter way?

Thanks for any advice.

Rob
:)

FND

unread,
May 12, 2008, 5:52:40 AM5/12/08
to Tiddl...@googlegroups.com
> I am already using
> the ReplaceDoubleClick plugin so that I can double click to select
> single words without opening up the tiddler for edit

Depending on what you want to do, you can just remove the plus sign from
the ViewTemplate shadow tiddler's toolbar:
http://www.tiddlywiki.org/wiki/Tiddler_Toolbar#Special_Symbols

> I would like to be able to tab into them
> and select all, as I would with a text field.

So you want a textarea - so basically just edit mode? (That would mean
you'd only see the raw wiki markup though... )


-- F.

Ouroboros

unread,
May 12, 2008, 1:51:46 PM5/12/08
to TiddlyWiki
I suggest giving Udo's Form plugin a look.
http://tiddlywiki.abego-software.de/#FormTiddlerPlugin

This will require a couple of other extensions, but the effect, shown
here with an example form
http://tiddlywiki.abego-software.de/#%5B%5BBiggerForm%20(Card%201)%5D%5D
would make the tiddler display a textarea (edit-able, save-able) in
display mode.

Eric Shulman

unread,
May 12, 2008, 3:40:14 PM5/12/08
to TiddlyWiki
> would make the tiddler display a textarea (edit-able, save-able) in
> display mode.

Try this:
http://www.TiddlyTools.com/#EditFieldPlugin

You can use this plugin to embed single- or multi-line input fields
into any tiddler content (or ViewTemplate definition). It can be used
to modify standard tiddler fields ("title" or "text"), as well as
custom fields using any fieldname you like!

This plugin works by extending the core's input field handling, so
that when
<<edit fieldname numberOfLines>>
is used in tiddler content, or:
<span macro='edit fieldname numberOfLines'></span>
is used in a ViewTemplate definition, you will be automatically
prompted to save/discard your changes (if any) as soon as you press
ENTER or move away ('onBlur' handling) from that input field (if the
content has been changed). You can also abandon your changes to input
field content by pressing ESCAPE (you will be asked to confirm before
discarding changes).

enjoy,
-e

Robert Mark Bram

unread,
May 12, 2008, 8:34:13 PM5/12/08
to TiddlyWiki
Hi Eric,

> > would make the tiddler display a textarea (edit-able, save-able) in
> > display mode.
>
> Try this:
> http://www.TiddlyTools.com/#EditFieldPlugin

This plugin is amazing - it allows me to put a text field into a
tiddler very easily.

Where are the values stored though? And how do I set initial values
for those fields? It wasn't obvious to me from the Javascript. :/

Rob
:)

Lyall

unread,
May 12, 2008, 9:01:35 PM5/12/08
to TiddlyWiki
I thought I would give this plugin a try.
I installed it in my 2.4 tiddlywiki using the good ol' TiddlyTools
ImportPlugin.
I went to edit the plugin to setup my tags and couldn't - input moved
down to the 'example fields'.
Not sure if it's conflict with other plugins or not, I do have quite a
few...


AdvancedOptionsPlugin
BackstageTweaksPlugin
BreadcrumbsPlugin
CalendarPlugin
CalendarPluginConfig
CollapseTiddlersPlugin
CookieJar
CookieManagerPlugin
CryptoFunctionsPlugin
DataTiddlerPlugin
DatePlugin
DatePluginConfig
DeprecatedFunctionsPlugin
DisableWikiLinksPlugin
ExportTiddlersPlugin
ForEachTiddlerPlugin
FormTiddlerPlugin
GotoPlugin
ImportTiddlersPlugin
ImprovedSlicesPlugin
InlineJavascriptPlugin
IntelliTaggerPlugin
IntelliTagsEditCommandPlugin
LaunchApplicationPlugin
PartTiddlerPlugin
RelatedTiddlersPlugin
SaveAsPlugin
SearchOptionsPlugin
SinglePageModePlugin
SnapshotPlugin
SplashScreenPlugin
TableOfContentsPlugin
TableSortingPlugin
TaggerPlugin
TextAreaPlugin
TiddlerEncryptionPlugin
TiddlerTweakerPlugin
TwabPlugin

...Lyall

Eric Shulman

unread,
May 12, 2008, 9:08:04 PM5/12/08
to TiddlyWiki
> Where are the values stored though? And how do I set initial values
> for those fields? It wasn't obvious to me from the Javascript. :/

The values are stored as internal "tiddler fields"... using either the
standard fieldnames ("title" or "text"), or any other custom field
name you like.

You can set the initial value when you create a tiddler using the
<<newTiddler>> macro:

For standard fields:
<<newTiddler title:"value" text:"value">>
For custom fields:
<<newTiddler fields:'fieldname:"value"'>>

(for custom fields, note the nested use of double-quotes surrounding
the value within single-quotes surrounding the 'fieldname:"value"'
syntax.)

enjoy,
-e

Eric Shulman

unread,
May 12, 2008, 9:16:41 PM5/12/08
to TiddlyWiki
> I went to edit the plugin to setup my tags and couldn't - input moved
> down to the 'example fields'.
> Not sure if it's conflict with other plugins or not, I do have quite a
> few...

hmmm... could be... but I'm not sure where...

you know the drill: disable all the plugins (or start with an empty
TW240) and add plugins one at a time until the problem re-appears.

While this can be a tedious process, but it's really the only way to
narrow the possibilities to the point where I can dig through the
relevant code to find the conflict (if that's the problem). Note:
EditFieldPlugin works properly in an empty TW240, and also in a fully
loaded copy of TiddlyTools, so I'd start by disabling all non-
TiddlyTools plugins. That should save some time...

Let me know what you find...

-e


Eric Shulman

unread,
May 12, 2008, 9:24:59 PM5/12/08
to TiddlyWiki
> The values are stored as internal "tiddler fields"... using either the
> standard fieldnames ("title" or "text"), or any other custom field
> name you like.

Addendum:
You can also use the "tags" standard field name to enter space-
separated tag values. This is particularly handy for updating a
tiddler's tags without entering edit mode!

-e

Lyall

unread,
May 12, 2008, 10:11:55 PM5/12/08
to TiddlyWiki
Subsequent reading of the plugin showed it was not quite what I was
looking for.
I was hoping it was a macro I could 'wrap' around some existing 'text'
in a tiddler that would put that 'text' in an input box so I could
edit the value, much like TWAB does in the Contacts pages.
Regardless, I will have another crack, just to try isolate the problem
tonight.

...Lyall

Lyall

unread,
May 13, 2008, 12:40:36 AM5/13/08
to TiddlyWiki
Interesting.
I downloaded an empty 2.4 TiddlyWiki from TiddlyWiki.com.
I downloaded the Current TiddlyTools.
I imported the EditFieldsPlugin from the TiddlyTools using standard
TiddlyWiki import.
I opened the EditFieldsPlugin tiddler.
The Edit button no longer worked. I was simply re-positioned to the
editing fields which displayed within the help area of the plugin.
Still, I persevered and Saved the tiddlywiki.
I then attempted to Shift-F5 (reload) the tiddlywiki and it informed
me I had not saved it.
I saved again.
I then attempted to Shift-F5 (reload) the tiddlywiki and it informed
me I had not saved it.
I saved again.
I refreshed and ignored the save message.
Now, the edit button is working.

It's weird, I did not think plugin code executed until re-load.

Anyway, the plugin works - just some unexpected behaviour on initial
import.

Eric Shulman

unread,
May 13, 2008, 1:24:43 AM5/13/08
to TiddlyWiki
> It's weird, I did not think plugin code executed until re-load.
> Anyway, the plugin works - just some unexpected behaviour on initial
> import.

Actually, it is precisely because the freshly imported plugin code has
*not* been executed that the odd behavior occurs. Here's why:

Unlike most plugins, EditFieldPlugin "hijacks" an *existing* core
macro, <<edit>>, to add the "view mode" handling. Thus, even though
the plugin code hasn't been executed, the core is still able to render
the edit fields contained in the "Examples" section of the plugin.

However, as soon as those edit fields are rendered, the core's
standard processing for config.macros.edit.handler() invokes
story.setDirty() for the tiddler, which tells the rest of the core
that the tiddler is now in "edit mode" (even though it really isn't!).

As a result of this "dirty" flag being set, when the core handler for
the "edit" toolbar command is subsequently invoked, the command simply
moves the focus to the rendered field that it believes is already part
of the editor (i.e., the textarea field in the example section),
instead of actually switching to the EditTemplate to truly enter into
edit mode.

The reason this problem goes away once the plugin has been properly
initialized (i.e., after a save-and-reload) is because of the
following two lines of code in the *hijacked* <<edit>> handler:

if (here && here.getAttribute("template").indexOf("ViewTemplate")!=-1)
{
story.setDirty(tiddler.title,false);

This code essentially forces the "dirty" flag set by core to be reset
when in "view mode", thereby permitting subsequent use of the "edit"
toolbar command to be properly processed so that the tiddler really
switches into "edit mode" when the toolbar command is invoked.

When I first wrote and tested this plugin last August, this very odd
behavior was the among the most subtle and puzzling problems that I
encountered. It took the rest of that day, and half of the next to
trace through the entire maze of tiddler "refresh" handling invoked by
the template switching logic to finally discover that the "dirty" flag
was the cause, and I distinctly remember having a gleefully self-
congratulatory "ah hah!" moment in which I reveled at my own
cleverness when I finally worked out the solution that made things
work as they were supposed to. :-)

Sometimes things are simple and obvious... and sometimes they are not.

-e
Reply all
Reply to author
Forward
0 new messages