Jump back to note marker from notes section

Get help using and writing Nisus Writer Pro macros.
Post Reply
m.danielsson
Posts: 12
Joined: 2014-07-12 03:21:50

Jump back to note marker from notes section

Post by m.danielsson » 2014-07-12 03:29:53

Macros to make it possible to return to the position after an inserted note in the text from the notes section with a shortcut. I find this useful. Perhaps some of you might agree with me.

There may be gotchas. It seems to not be possible to insert notes in textboxes and tables so those are not a problem. When it becomes possible to do so, the macro may become less useful... Perhaps someone is aware of cases where swapWithMark: does not work?


Regards,
Martin


-- noteJumpBack
#Use with footnoteInsert or endnoteInsert, macro replacements of ‘Footnote’
#and ‘Endnote’, which sets a mark before inserting the note as a position to
#jump back to. NWP can’t swap with a mark in the main document from a notes section
#so text needs to be inserted in the main document to place the cursor at position
#from where a swap is possible.

$doc = Document.active
$text = $doc.text
$text.insertAtIndex 0, ‘[NWPnoteMark]’
$range = Range.new(0, 13)
$text.deleteInRange($range)

Send Selector ‘swapWithMark:’
Send Selector ‘moveRight:’

-- footnoteInsert
# Set mark before inserting footnote for noteJumpBack to swap with
# from the notes section.

Send Selector ‘setMark:’
Menu ‘Insert:Footnote’

-- endnoteInsert
# Set mark before inserting endnote for noteJumpBack to swap with
# from the notes section.

Send Selector ‘setMark:’
Menu ‘Insert:Endnote’

User avatar
martin
Official Nisus Person
Posts: 4370
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Jump back to note marker from notes section

Post by martin » 2014-07-14 13:36:08

Thank you for sharing your macros Martin. I actually wasn't aware of the "setMark:" and "swapWithMark:" selectors, but it seems they are part of Apple's Cocoa/AppKit framework, which NWP uses.

I should however say that you don't need a macro to return to the main document after inserting a footnote or endnote. You could just use the menu Edit > Select > Previous Selection. That command will restore prior selections as recorded in the selection history. If you edited and selected a variety of things inside your newly inserted note, you may need to activate that menu a few times to restore the selection in the main document body. This is a handy menu command for a variety of editing situations, and I usually use a keyboard shortcut to activate it.

Another more direct solution is to use the menu View > Go to Note References. If the selection currently rests inside a note area, it will always return you to the note reference in the main body. It's also useful in the opposite situation: if the note reference is currently selected in the main document, the menu will instead take you to the note area.

m.danielsson
Posts: 12
Joined: 2014-07-12 03:21:50

Re: Jump back to note marker from notes section

Post by m.danielsson » 2014-07-15 05:15:57

Thanks! Apart from being better in all ways, the built-in that I missed (hmmmm) will not break...

Also, thanks for the tip about "previous selection"! That looks useful.

If someone is interested the selectors that can be used in NWP are listed under "Responding to Action Messages":
https://developer.apple.com/library/mac ... rence.html

These selectors can be used in all applications using Cocoa's Text System by editing or creating " ~/Library/KeyBindings/DefaultKeyBinding.dict". An article describing customization this way is available at:
http://web.archive.org/web/201004131734 ... -text.html.
It may not be that useful in NWP which has a lot built in and Macros, but there are things like HTML forms etc. which one tends to use often.

Regards,
Martin

User avatar
Hamid
Posts: 734
Joined: 2007-01-17 03:25:42

Re: Jump back to note marker from notes section

Post by Hamid » 2014-07-15 07:47:34

If the selection currently rests inside a note area, you can also return to the note reference in the main body by pressing the escape key.

Þorvarður
Posts: 256
Joined: 2012-12-19 05:02:52

Re: Jump back to note marker from notes section

Post by Þorvarður » 2014-07-16 02:07:59

Thanks for the escape key tip, Hamid. I was not aware that we could do that.:-)

Regarding going to the note area and back again, a simple double-click is also easier and faster than executing menu commands. If the selection currently rests inside a note area, a double-click on the note number will always return you to the note reference in the main body, and vice versa.

m.danielsson
Posts: 12
Joined: 2014-07-12 03:21:50

Re: Jump back to note marker from notes section

Post by m.danielsson » 2014-07-16 07:36:56

Thanks Hamid and Þorvarður. Escape doesn't seem to work for me, but I have made a shortcut to "Go to Note" which goes both goes back and forth to the notes area. And hitting the shortcut when the cursor isn't immediately after the note reference jumps back to the reference of latest note added and hitting it again takes me to the note. I am very satisfied. Also good to know that double clicking works.

Of course, I am also slightly embarrassed ;)

Regards,
Martin

User avatar
martin
Official Nisus Person
Posts: 4370
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Jump back to note marker from notes section

Post by martin » 2014-07-16 12:15:13

m.danielsson wrote:Of course, I am also slightly embarrassed ;)
Please don't be! It's great that you were trying to improve this situation yourself and were kind enough to share your efforts. I'm happy everyone could get involved and share their knowledge.

Post Reply