Skip to main content
Olivier Beltrami
Legend
March 27, 2025
Question

Equivalent to kTextChar_FrameBoxBreak for "next cell"

  • March 27, 2025
  • 3 replies
  • 993 views

Hello,

In my C++ code I am using the character kTextChar_FrameBoxBreak to make my text jump to the next chained/linked box, and kTextChar_ColumnBreak to make text jump to the next column, and both work fine.

But I cannot find the equivalent character to make text jump to the next cell of a table.

In the InDesign UI typing TAB moves the insertion point to the next cell, but using a tab char in my code does not jump to the next cell (all tabs are placed in the same initial cell).

Does anyone know what the code is ?

Very best regards,

Olivier

3 replies

Legend
March 27, 2025

An alternative: use any character, e.g. tab as column separator, return as row separator.

Then use the equivalent to menu Table >> Convert Text to Table … .

ITableUtils::ConvertTextToTable() should do, or the same in ITableSuite .

 

Robert at ID-Tasker
Legend
March 27, 2025

@Dirk Becker

 

But it could create a mess with more "complicated" Tables? Especially with multiple Paragraphs as Cell's contents?

 

Legend
March 27, 2025

@Robert at ID-Tasker

Sure it can get more complicated, but only in leap years.

7 14 21 28 4 11 18 25 1 8

Inspiring
March 27, 2025

You should think of each cell in a table as its own text frame - they are not contiguously linked the way that columns in a text frame or linked text frames across a story are. Rather, each cell is in a way its own story.  It's complicated in the C++ API, because there is one ITextModel that spans all the linked frames as well as all the contained tables, but within the text model there are a set of ITextStoryThread objects, managed by an ITextStoryThreadDict. Examples of ITextStoryThread objects include table cells, footnotes, notes, text macros, and deleted text. See ITextStoryThread.h for a better explanation.

 

To fully answer your question, you'll need to be more specific about what you're trying to achieve. Are you trying to actually set the selection in each cell? Are you trying to insert text in each cell? You may want to look at the table model iterator as a way to iterate through the cells of a table model:

ITableModel::iterator tableItr(tableModel->begin());
ITableModel::iterator tableItrEnd(tableModel->end());

for(; tableItr != tableItrEnd; ++tableItr)
{
	InterfacePtr<ICellContent> cellContent(tableModel->QueryCellContentBoss(*tableItr));
	if(cellContent == nil)
	{
		ASSERT(cellContent);
		break;
	}
	
	InterfacePtr<ITextStoryThread> textStoryThread(cellContent, UseDefaultIID());
	if(textStoryThread == nil)
	{
		ASSERT(textStoryThread);
		break;
	}
	
	TextIndex startIndex = textStoryThread->GetTextStart();
	TextIndex endIndex = textStoryThread->GetTextEnd();

[do whatever you need here]

But it's hard to fully answer without knowing more what you're trying to achieve.

Olivier Beltrami
Legend
March 27, 2025

@Lawrence Horwitz Thank you very much for your response.

Below is an example of what I am doing, using linked/chained frames. A token in the first frame generates text which flows across the linked frames by the insertiion of a kTextChar_FrameBoxBreak between each date. I was hoping to be able to do the same with a table; have the token in the first cell and have the generated text flow into cells. 

 

Inspiring
March 27, 2025

Hi Oliver, that clarifies things. You won't be able to insert a character to jump between the cells of a table. Text does not flow from one cell to the next the way it does in text columns or in linked text frames.

 

Instead, try using the iterator I mentioned above. Once you have the beginning text index for a cell, you can insert text into the story just the way you do for any other text. By using that index, what you insert will go into the given cell. I believe you should be able to use the iterator to jump to the next cell after even after inserting new text and you should still get the correct text index for the next cell.

 

There are other ways of addressing cells using grid addresses if you need more control over the iteration, but it gets complicated because of the ways that cells can be merged. Given that your example shows a table with a single row, I think using the iterator is probably your best bet.

Community Expert
March 27, 2025

Hi @Olivier Beltrami I don't think there is any break character for changing the cell. The tab key is actually not inserting any character but acts like a shortcut for an action. I think you will explicitly have to target the insertionpoint in the desired cell.

-Manan 

-Manan