Welcome, Guest. Please Login
Rorohiko Workflow Resources
  Welcome the Message Board of Rorohiko Workflow Resources. To register, please e-mail [email protected] - automatic registration has been turned off because of relentless spambots and spammers. This Message Board is not actively monitored. If you have an urgent question, please e-mail [email protected]. If you post it here, it will probably be many weeks before we notice.
  HomeHelpSearchLogin  
 
Page Index Toggle Pages: 1
Send Topic Print
Can Active Page Items do . . . (Read 10012 times)
roger purves
YaBB Newbies
*
Offline



Posts: 3
Can Active Page Items do . . .
09/16/06 at 17:23:51
 
to the forum:

I am trying to get an idea of what Active Page Items
is capable of. For example, could it be
used to make “switches” that turn on
some javascript as a result of dragging
and dropping?

To be specific, imagine you have a short
vertical line segment, and beside it a small
square. (These are not part of the document
you are working on.) You have some lines of
javascript that do something to one or more of
the page elements of your document. In that
setting, can you use Active Page Items to arrange
the following behavior? Whenever you select the square,
drag it to the other side of the vertical segment and
there drop it, the javascript is run.

If there were many such switches populating an InDesign
document would Active Page Items be responsive to these
switches (on a machine where InDesign itself is reasonably fast)?

I hope these two queries are clear enough to answer.

Thank you,

Roger Purves


Back to top
 
 
IP Logged
 
Kris Coppieters
YaBB Administrator
*****
Offline



Posts: 181
New Zealand
Gender: male
Re: Can Active Page Items do . . .
Reply #1 - 09/16/06 at 17:42:59
 
Dear Roger,

I am not 100% sure I understand, but I think the answer is yes.

Active Page Items has a 'modified' event which allows you to run an event handler attached to a page item each time something about the page item is modified (e.g. its position).

In this case, I'd attach a JavaScript to the square, and when the modified event is received, have it check its position relative to the line. If it is in a position that should cause processing, it can activate the script.

Maybe you could give me some more specifics of what you are trying to achieve?

Thanks!

Kriws
Back to top
 

Kris
WWW  
IP Logged
 
roger purves
YaBB Newbies
*
Offline



Posts: 3
Re: Can Active Page Items do . . .
Reply #2 - 09/17/06 at 19:05:53
 
to Kris:

Your reply is encouraging, and it leads me
to a request. Would you be willing to
post the javascript that would
be attached to the square? To keep
things as simple as possible, ignore
the vertical line segment, and choose
any condition you want for the dragging;
e.g. drag square and drop at any position
where the x-coordinate of the upper
left hand corner of the square is less than
(say) 200 points. (And assume the initial
position of the square does not satisfy
the condition.) When the square is dropped
(mouse button released), a “hello world”
should be displayed somewhere in the document.
(I can write the “hello world” part, so all
you need to indicate is

        “hello world” part goes here

in your posted javascript.)

If this request asks too much, even a comment
to that effect will be quite helpful. It will give me
an idea of the difficulty I might have working with
Active Page Items. I am only modestly adept with
javascript and have only used it in the fairly
non-interactive environment provided by InDesign.

I can't be  specific about what I am trying to do
with Active Page Items, except to say that I
hope to use it to add some interface elements
to InDesign. InDesign is not as visual as I would
like it to be.

Thank you for your helpful reply to my first post.

Roger Purves

PS. I like the way this input window respects the
spacebar. Apple's forums don't.

Back to top
 
 
IP Logged
 
Kris Coppieters
YaBB Administrator
*****
Offline



Posts: 181
New Zealand
Gender: male
Re: Can Active Page Items do . . .
Reply #3 - 09/18/06 at 12:19:44
 
Dear Roger,

Try this (using the demo version of APID):

1) Create some square page item, and select it
2) If not visible, bring up the Active Page Item Developer palette (with the square still selected)
3) Enter the word 'modified' in the 'Event Filter' field. Leave the two others (Script Label and List of Subjects) empty.

Enter the following JavaScript in the main text entry zone on the palette:


if (theItem.geometricBounds[0] < 100)
{
 alert("Hello World - my vertical position is < 100");
}


Click somewhere in the page area to deselect  the square.

Now start dragging the square around. If you position it in the top area of the page, the dialog will appear after each move. If you drop it in the bottom half of the page, no dialog will appear.

Is this what you were looking for?

Cheers,

Kris
Back to top
 

Kris
WWW  
IP Logged
 
roger purves
YaBB Newbies
*
Offline



Posts: 3
Re: Can Active Page Items do . . .
Reply #4 - 09/19/06 at 17:39:48
 
to Kris:

That is just the guidance I was looking for.
Thank you for taking the time to set
it down so clearly. As soon as I get a
chance, which may not be until the
weekend, I will try out the procedure
you outlined.

Roger
Back to top
 
 
IP Logged
 
Kris Coppieters
YaBB Administrator
*****
Offline



Posts: 181
New Zealand
Gender: male
Re: Can Active Page Items do . . .
Reply #5 - 09/19/06 at 18:25:31
 
Hi Roger,

Great!

Now, if you think Active Page Items can help you out - please do make time to review the cookbook.

The cookbook contains a lot of information than should help you avoid all the mistakes we've made over time when we started using Active Page Items.

The example code I've shown you is good to get a general idea of how Active Page Items 'thinks'. Play around with it, build on it, muck around with it.

But when you eventually jump into a 'real' project, then you should consider a slightly more elaborate project structure (in short: we advocate keeping the 'meat' of the API project outside of the InDesign file, in a separate, external .jsx file. The APIDTemplate.indd should assist in doing just that).

All embedded handlers should be very short - in essence nothing more than calls (.handleScriptEvent())  to the 'centralized' body of source code in the .jsx file...

You might also set up a 'controller' which watches for 'subjectModified' events - that would avoid having to store a handler in the individual page items. All that is explained in the cookbook through some hands-on examples...





Back to top
 

Kris
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print