Reply to topic  [ 7 posts ] 
Jump back to note marker from notes section 
Author Message

Joined: 2014-07-12 03:21:50
Posts: 12
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’


2014-07-12 03:29:53
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.


2014-07-14 13:36:08
Profile WWW

Joined: 2014-07-12 03:21:50
Posts: 12
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


2014-07-15 05:15:57
Profile
User avatar

Joined: 2007-01-17 03:25:42
Posts: 729
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.


2014-07-15 07:47:34
Profile

Joined: 2012-12-19 05:02:52
Posts: 225
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.


2014-07-16 02:07:59
Profile

Joined: 2014-07-12 03:21:50
Posts: 12
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


2014-07-16 07:36:56
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.


2014-07-16 12:15:13
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software