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
Table cell text modification - which event? (Read 9793 times)
WellerUK
YaBB Newbies
*
Offline



Posts: 5
Table cell text modification - which event?
02/15/11 at 05:07:11
 
Hi
I'm trying to reliably get a reference to the cell being edited by user.
Ideally I'd like to find the cell object in `theItem.eventSource` after it's been deselected. I tried experimenting with `subject*elected*` and various  subject text-events without much success.
The problem is, that I only get reference to the textframe or story containing the table.
I considered checking app.selection[0] right after some text-related event fires,  but I find this approach unreliable.

Can anyone help me please?
APID 1.0.49.3
ID 7.0.3

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



Posts: 181
New Zealand
Gender: male
Re: Table cell text modification - which event?
Reply #1 - 02/15/11 at 07:14:11
 
Hi Weller,

I'll have a look - I don't recall off the top of my head, but as far as I remember, you need to calculate the cell from the current selection after you receive a text modified event on the text story - the 'unreliable' approach. Care to elaborate on what you find to be unreliable about the approach? I am pretty sure I used it successfully.

I am not in the office right now - not sure how fast I'll be able to check it out - stay tuned...

Cheers,

Kris
Back to top
 

Kris
WWW  
IP Logged
 
Harbs
YaBB Newbies
*
Offline


Kris Does Great Work ;-)
!

Posts: 13
Gender: male
Re: Table cell text modification - which event?
Reply #2 - 02/15/11 at 07:19:13
 
This is a complicated problem.

The way I'd probably handle it would be with two text related events. The first would have a very short (or 0) delay and the only thing you do in that event would be to record the selection. In the second event, you pick up the saved selection info, and process based on that...

HTH,
Harbs
Back to top
 
WWW  
IP Logged
 
weller
YaBB Newbies
*
Offline


I Love YaBB 2!

Posts: 10
Re: Table cell text modification - which event?
Reply #3 - 02/15/11 at 10:19:33
 
Kris Coppieters wrote on 02/15/11 at 07:14:11:
Hi Weller,
... the 'unreliable' approach. Care to elaborate on what you find to be unreliable about the approach?
Kris


My InDesign document is a product catalogue. It needs to stay in sync with the database. So on opening the document it will load the list of changes since last database access and applies them. This is handled by MySQL <-> Python HTTP server <-> extendScript Socket.

However the link must work both ways. The idea was to build a list of relevant changes in InDesign while they happen and send it through the Socket object onSave. This works nicely for plain textFrames and changes to applied styles.
But when the tables are involved (mainly for pricing) users tend type & tab furiously through the cells ant there's no guarantee that the cursor stays in the text that fired the event (even with the 0ms delay).

I know that I can send every price from the table to the database, knowing that it will ignore any unchanged values. The whole system is on local network so I can happily waste bandwidth in a belt-and-braces way. I still hope there is cleaner way. I also fear that user may experience unnacceptable timeouts after each typed character when working on larger tables (1 - 500 rows)

I'm sorry for the verbosity, hope it showed what I'm trying to achieve and what I'm trying to avoid.

Thanks for help
Back to top
 
 
IP Logged
 
Kris Coppieters
YaBB Administrator
*****
Offline



Posts: 181
New Zealand
Gender: male
Re: Table cell text modification - which event?
Reply #4 - 02/15/11 at 12:37:07
 
Hmm... That type of situation, I tend to resolve with some caching. Here's a rough description of how I'd try to handle it:

1) When the document opens or is updated from the DB, I'd grab a cached copy of the table contents and store it into some page objects datastore. The idea is that you have a copy of the data 'as the database sees it' in your document.
2) When the user starts modifying stuff, all you do is set one or more flags which signify 'stuff was modified'. You don't care what exactly was modified, nor do you try to update the database.
3) You register an idle event handler, and after enough time has passed, you check for 'stuff was modified' flags. If one of the flags is set, you compare the current contents of the table on the page to your cached copy and you find out what cells were modified. You send those to the database, and update your cached copy 'as the database sees it'

The idea is that you wait for a quiet time, and then compare the cached data from the DB with what the document currently has, and only send through updates when there is actually something to update.

Would that work?

Cheers,

Kris
Back to top
 

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