void
JXTextMenuData::InsertItem
	(
	const JIndex		index,
	const JCharacter*	str,
	const JBoolean		isCheckbox,
	const JBoolean		isRadio,
	const JCharacter*	shortcuts,
	const JCharacter*	nmShortcut,
	const JCharacter*	id
	)
{
	JString* text = new JString(str);
	assert( text != NULL );

	TextItemData itemData(text, itsDefFontID, itsDefFontSize, itsDefFontStyle);
	itsTextItemData->InsertElementAtIndex(index, itemData);

	JXMenuData::InsertItem(index, isCheckbox, isRadio, shortcuts, id);

	const JString* s;
	GetItemShortcuts(index, &s);
	itemData.ulIndex = JXWindow::GetULShortcutIndex(*(itemData.text), s);
	itsTextItemData->SetElement(index, itemData);

	(itsMenu->GetWindow())->MenuItemInserted(itsMenu, index);
	itsNeedGeomRecalcFlag = kJTrue;

	SetNMShortcut(index, nmShortcut);	// parse it and register it
}
void
JXStringCompletionMenu::CompletionRequested
	(
	const JSize prefixLength
	)
{
	itsRequestCount++;
	if (itsRequestCount > 1 && !IsEmpty())
		{
		itsPrefixLength = prefixLength;

		// prepend "insert tab character" option

		JString s;
		if (itsAllowTabChar &&
			(!GetItemShortcuts(1, &s) || s != kInsertTabShortcut))
			{
			PrependItem(kInsertTabStr, kPlainType, kInsertTabShortcut);
			}

		// place it next to the caret (use the character in front of the caret)

		const JIndex charIndex = itsTE->GetInsertionIndex() - 1;
		const JCoordinate x    = itsTE->GetCharRight(charIndex) + 2;
		const JIndex lineIndex = itsTE->GetLineForChar(charIndex);
		const JCoordinate y    = itsTE->GetLineTop(lineIndex) - GetFrameHeight();
		Place(x,y);

		// open it

		HandleShortcut('\t', JXKeyModifiers(GetDisplay()));
		}
}
void
JXTextMenuData::SetText
	(
	const JIndex		index,
	const JCharacter*	str
	)
{
	TextItemData itemData = itsTextItemData->GetElement(index);
	*(itemData.text) = str;

	const JString* shortcuts;
	GetItemShortcuts(index, &shortcuts);
	itemData.ulIndex = JXWindow::GetULShortcutIndex(*(itemData.text), shortcuts);
	itsTextItemData->SetElement(index, itemData);

	itsNeedGeomRecalcFlag = kJTrue;
}