Copy link to clipboard
Copied
Hi,
I need to drop static text from a panel to the document. Since its simple text, I believe I dont need to handle the drop target. For drag source, I am handling it like the code below. It does add the Undo item (meaning the drop happened successfully) but doesnt appned the text where dropped. Any pointers will be helpful.
I am attaching the modified basicdragdrop sample plugin here which tries to insert a hardcoded sample text into the document when dragging the "DragMe" text. On drop, the sample text is not being appended to the text frame.
Thanks
Rupesh
bool16
WLBPropertiesDragSource::DoAddDragContent(IDragDropController* controller)
{
bool16 result = kFalse;
// do while(false) loop for error control
do
{
PMString prop;
if (this->GetDraggedString(prop) == kFalse)
break;
InterfacePtr<IDataExchangeHandler> ourHandler(controller->QueryHandler(kPMTextFlavor));
if (ourHandler == nil)
break;
InterfacePtr<ITextScrapData> tsd(ourHandler, IID_ITEXTSCRAPDATA);
if (tsd == nil)
break;
InterfacePtr<ITextModel> model(tsd->GetStoryRef(), UseDefaultIID());
IDataBase* db = GetSourceDataBase();
InterfacePtr<ITextModelCmds> textModelCmds(model, UseDefaultIID());
if (!textModelCmds)
break;
boost::shared_ptr<WideString> string(new WideString(prop));
InterfacePtr<ICommand> insertCmd(textModelCmds->InsertCmd(kInvalidTextIndex, string)); // do make a copy
ASSERT(insertCmd);
if (!insertCmd) {
break;
}
CmdUtils::ProcessCommand(insertCmd);
tsd->Set(db, model, kFalse);
controller->SetSourceHandler(ourHandler);
InterfacePtr<IPMDataObject> pmDataObject(controller->AddDragItem(1));
ASSERT(pmDataObject);
PMFlavorFlags flavorFlags = kNormalFlavorFlag;
pmDataObject->PromiseFlavor(kPMTextFlavor, flavorFlags);
result = kTrue;
} while (false);
return result;
}
Thanks.
Copy link to clipboard
Copied
Hi,
I will need to investigate, but I am pretty sure if you are wanting it to add to a grapphic frame that you are dropping on you would need to the drop target, if you look at the sample BasicDragDrop.sdk sample, it has to create a new page item to place the information.
Regards
Malcolm
Copy link to clipboard
Copied
Thanks Malcolm.
Not exactly. I have a panel with a list box full of some custom properties as static text. I need to drag that property from the list box to the document and drop on any page item which can accept and append simple text to itself. Somewhat similar drag behavior to what "Data Merge" plug in does.
Thanks.
Copy link to clipboard
Copied
Data Merge UI has kDMPageItemDDTargetFlavorHelperBoss and kDMTablesDDTargetFlavorHelperBoss. I have not looked though whether they are involved in any text related flavor.