AIS_InteractiveContext returns zero Selected Shape when there is clearly a AISObject selected?

So I have the following code. I just override the HandleMouseClick, the virtual function of SelectMgr_EntityOwner, to make my own.

Standard_Boolean CustomizedOwner::HandleMouseClick(const Graphic3d_Vec2i & thePoint, Aspect_VKeyMouse theButton, Aspect_VKeyFlags theModifiers, bool theIsDoubleClick)

Handle(SelectMgr_SelectableObject) Obj = this->Selectable();
Handle(AIS_InteractiveObject) AISObj = Handle(AIS_InteractiveObject)::DownCast(Obj);

AIS_InteractiveContext* ctx = AISObj->InteractiveContext();

wprintf(L"selected elements: %d\n", ctx->NbSelected());
wprintf(L"are there more than own element: %s\n", ctx->MoreSelected()?L"true":L"false");

return false;

The PROBLEM is that AIS_InteractiveContext retrieved gives zero selected objects/elements. That is the print outs gives

"selected elements: 0"
"are there more than own element: false"

Kirill Gavrilov's picture

HandleMouseClick() is called before selection happens, moreover it's return value is used to decide if this object should be selected or not. If you want to track selection changes, you may override method AIS_ViewController::OnSelectionChanged().