Hi Alberto,

Yes, I have done this for my TW5 (pespot.tiddlyspot.com). What I did was to 
modify the navigator widget and add a new message called "new."

var NavigatorWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
this.addEventListeners([
{type: "tm-navigate", handler: "handleNavigateEvent"},
{type: "tm-edit-tiddler", handler: "handleEditTiddlerEvent"},
{type: "tm-delete-tiddler", handler: "handleDeleteTiddlerEvent"},
{type: "tm-save-tiddler", handler: "handleSaveTiddlerEvent"},
{type: "tm-cancel-tiddler", handler: "handleCancelTiddlerEvent"},
{type: "tm-close-tiddler", handler: "handleCloseTiddlerEvent"},
{type: "tm-close-all-tiddlers", handler: "handleCloseAllTiddlersEvent"},
{type: "tm-close-other-tiddlers", handler: "handleCloseOtherTiddlersEvent"},
{type: "tm-new-tiddler", handler: "handleNewTiddlerEvent"},
---> {type: "new", handler: "handleNewEvent"},
{type: "tm-import-tiddlers", handler: "handleImportTiddlersEvent"},
{type: "tm-perform-import", handler: "handlePerformImportEvent"}
]);
};

Then I copied the code for "handleNewTiddlerEvent" and changed it so that 
it doesn't create add the draft of the new tiddler to the top of the story. 
Add this in the navigator widget somewhere:

NavigatorWidget.prototype.handleNewEvent = function(event) {
// Get the story details
var storyList = this.getStoryList(),
templateTiddler, additionalFields, title, draftTitle, existingTiddler;
// Get the template tiddler (if any)
if(typeof event.param === "string") {
// Get the template tiddler
templateTiddler = this.wiki.getTiddler(event.param);
// Generate a new title
title = this.wiki.generateNewTitle(event.param || 
$tw.language.getString("DefaultNewTiddlerTitle"));
}
// Get the specified additional fields
if(typeof event.paramObject === "object") {
additionalFields = event.paramObject;
}
if(additionalFields && additionalFields.title) {
title = additionalFields.title;
}
// Generate a title if we don't have one
title = title || 
this.wiki.generateNewTitle($tw.language.getString("DefaultNewTiddlerTitle"));
// Find any existing draft for this tiddler
draftTitle = this.wiki.findDraft(title);
// Pull in any existing tiddler
if(draftTitle) {
existingTiddler = this.wiki.getTiddler(draftTitle);
} else {
existingTiddler = this.wiki.getTiddler(title);
}
// Merge the tags
var mergedTags = [];
if(existingTiddler && existingTiddler.fields.tags) {
$tw.utils.pushTop(mergedTags,existingTiddler.fields.tags)
}
if(additionalFields && additionalFields.tags) {
// Merge tags
mergedTags = 
$tw.utils.pushTop(mergedTags,$tw.utils.parseStringArray(additionalFields.tags));
}
if(templateTiddler && templateTiddler.fields.tags) {
// Merge tags
mergedTags = $tw.utils.pushTop(mergedTags,templateTiddler.fields.tags);
}
var draftTiddler = new $tw.Tiddler({
text: "",
},
templateTiddler,
existingTiddler,
additionalFields,
this.wiki.getCreationFields(),
{
title: title,
tags: mergedTags
},this.wiki.getModificationFields());
this.wiki.addTiddler(draftTiddler);
// Add a new record to the top of the history stack
this.addToHistory(title);
return false;
};

Then you can trigger this to happen the same way you would use a 
"tm-new-tiddler" message, for example, with a button:

<$action-sendmessage  $message="new" $param=$template$/>

This is a super convenient option to have on hand.

On Friday, January 30, 2015 at 9:55:57 AM UTC-5, Alberto Molina wrote:
>
> Hi all, 
>
> When setting a field (action-setfield) of a non-existing tiddler, that 
> tiddler is created silently : it doesn't open in edit mode nor shows itself 
> in the story river. 
>
> Is there a way to get the same behaviour  when creating a new tiddler with 
> tm-new-tiddler messages? 
>
> Regards, 
>
> Alberto 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to