Top of Page Macro?

Get help using and writing Nisus Writer Pro macros.
Post Reply
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Top of Page Macro?

Post by bjast »

Perhaps it exists already, but is there a way to write a macro to place the cursor at the top of the present page?

Thanks
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Top of Page Macro?

Post by Kino »

Does this macro meet your needs?

Code: Select all

$sel = TextSelection.active
if $sel == undefined
	exit
end

$i = $sel.location
if $i == $sel.text.length
	if $i != 0
		$i -= 1
	end
end
$n = $sel.text.pageNumberAtIndex $i
Select Page $n
Select Start
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Top of Page Macro?

Post by bjast »

Thanks Kino for a quick reply to this.

It kinda does what I had in mind, but it doesn't always go to the top of the page - at least as the page appears on the screen. Perhaps this is asking too much of NWP.

What I was hoping for was to have the cursor go to the top of screen from any place in the open document. For instance if the cursor was presently at, say, two thirds of the way down the screen, the macro would move the cursor to the top of the screen, rather than the top of the page - tricky, I admit.

Any ideas?
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Top of Page Macro?

Post by Kino »

Unfortunately that is not feasible because it is impossible for a macro to know which portion of a document is actually visible.
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Top of Page Macro?

Post by bjast »

That's what I was afraid of. But I can use the one you sent me, as it get closer than anything that I could come up with.

Thanks
Post Reply