Since I keep pressing CTRL+Enter and ESC when editing sections in the
EditSectionPlugin popup (which doesn't do anything), I added these keyboard
shortcuts for "save" and "cancel," respectively.
I'll post my additions in case they can help anyone else. Maybe Eric will
even update his plugin some day. I'm not sure this is the ideal way to
handle things, as I did neither write the core or the plugin, but it works
for me.
Changes in EditSectionPlugin v1.8.1:
in createPanel:
this.showPanel(p,here,ev);
jQuery(f).find("TEXTAREA").focus();
return this.ok(ev);
in initForm:
form.content.value=store.getTiddlerText(tid,'');
jQuery(form).keydown( function(eventObject) { // add a keyboard handler to
the form element
if (eventObject.which == 27)
config.macros.editSection.cancel(this,eventObject); // ESC pressed
if (eventObject.which == 13 && eventObject.ctrlKey)
config.macros.editSection.saveForm(this,eventObject); // Ctrl-Enter pressed
});
if (version.extensions.TextAreaPlugin) new
window.TextAreaResizer(form.content);
in saveForm:
replace
var f=here.form;
with
var f=(here.form ? here.form : here); // check for events attached to the
form itself
in cancel:
replace
this.removePanel(here.form.panel);
with
here.form ? this.removePanel(here.form.panel) :
this.removePanel(here.panel); // check for events attached to form itself
The keyboard event is attached to the form element. Therefore the called
methods saveForm and cancel must be changed to account for the possibility
of being called with here referring to the form, not just an element in the
form. The textarea element is given focus upon opening the popup so that
immediately pressing ESC works (otherwise this event gets sent to the popup
window instead of the form).
I hope this is of use to someone,
Yaisog.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/tiddlywikidev/-/i_3sgUh-B30J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywikidev?hl=en.