Step 3: Adding an Object Interactor
In this step we show the usage of the object interactor
IlvGraphicComAdapterInteractor (this class is defined in the header file
ilviews/windows/comgint.h). It lets you interact with the control (although there are some limitations) even when you apply a transformation to the graphic object. In fact, you just have to attach an instance of the
IlvGraphicComAdapterInteractor to the
IlvGraphicCOMAdapter object, which is accomplished with the function
AttachInteractorAccelerator:
void
AttachInteractorAccelerator(IlvManager* man,
IlvView*,
IlvEvent& ev,
IlvAny arg)
{
// The arg parameter is actually an object interactor.
IlvManagerObjectInteractor* inter =
ILVREINTERPRETCAST(IlvObjectInteractor*, arg);
// Gets the object above which is the mouse pointer.
IlvGraphic* graphic = man->lastContains(IlvPoint(ev.x(), ev.y()));
// Any object?
if (graphic) {
// Is it an IlvGraphicCOMAdapter?
IlvGraphicCOMAdapter* adapt =
ILVDYNAMICCAST(IlvGraphicCOMAdapter*, graphic);
if (adapt) {
// Attaches the interactor to the object.
adapt->setInteractor(inter);
}
}
}
The
IlvGraphicComAdapterInteractor object is given as a parameter of the function and was allocated in the function
ActiveXGraphicAdapter::specificInitialization:
_objectInteractor = new IlvGraphicComAdapterInteractor;
// Adds an accelerator in order to attach an object interactor to the
// control under the mouse pointer.
grapher->addAccelerator(AttachInteractorAccelerator,
IlvKeyUp,
IlvCtrlChar('b'),
0,
_objectInteractor);
Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.