Message Board for Rorohiko Workflow Resources
https://www.rorohiko.com/cgi-bin/yabb2/YaBB.pl
General Category >> General Board >> APID - "modified-text" event for cells' contents
https://www.rorohiko.com/cgi-bin/yabb2/YaBB.pl?num=1213211131

Message started by weller on 06/12/08 at 07:05:31

Title: APID - "modified-text" event for cells' contents
Post by weller on 06/12/08 at 07:05:31
Is there a way to run script when user types into table cell?

Thanks for help
weller





Great work Kris. Adobe should ship APID with every copy and pay you 100% price for each license sold. Or you should charge twenty times more for it. (Just wait coupla days with the price rise until I'll upgrade to APID for CS3 please)

Title: Re: APID - "modified-text" event for cells' conten
Post by Kris Coppieters on 06/12/08 at 09:01:02
Hi Weller,

Thanks for the appreciation!

Handling that should work via an observer object - i.e. set up a separate observing page item (or scripted plug-in proxy like APIDTemplate provides), and set the event filter to 'subjectModified-usertyping' or 'subjectModified-text', and subject list to '*'.

Each time a cell (or anything else) is typed in, you'd get this event. Your script would still need to figure out whether the typing occurred in a table, what cell and so on - probably from app.selection - which would be an InsertionPoint at that time...

Does that help?

Cheers,

Kris

Title: Re: APID - "modified-text" event for cells' conten
Post by WellerUK on 06/13/08 at 00:11:37
Thanks Kris
It works perfectly. I've noticed that there's no 3000ms delay which is usual on regular text frames. I tried to fiddle with $.sleep() function, but that will only slow the script execution. What I need is to allow the user to type few characters before the script will take command over InDesign.

Thanks

Title: Re: APID - "modified-text" event for cells' conten
Post by Kris Coppieters on 06/13/08 at 11:27:00
Hi WellerUK,

That is easy to accomplish, I think. Check the code sample below - I have a frame on the pasteboard, which has its list of subjects set to "*", and its event filter to "selected,subjectModified-usertyping" so it reacts to being selected, and on any of its subjects being typed into.

The script is:


if (theItem.eventCode == "selected")
{
 theItem.setDataStore("$DELAY_subjectModified-usertyping$",3000);
}
else
{
 alert("Typing");
}


So when I select the page item on the pasteboard it sets a predefined data store entry which is the delay value for the subjectModified-usertyping event on that page item. This way, if the user types away, nothing happens, until the user pauses for 3 or more seconds.

That should do the trick, I hope...

Cheers,

Kris

Title: Re: APID - "modified-text" event for cells' conten
Post by WellerUK on 06/13/08 at 20:50:48
Thanks Kris

It did the job. I've found it in the documentation later but it was too late because I'd already bothered you with stupid RTFM question. Sorry for that.

Thanks for help
weller

Message Board for Rorohiko Workflow Resources » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2024. All Rights Reserved.