mr3@ukc.ac.uk (M.Rizzo) (06/06/91)
In article <1991Jun5.141228@Pkg.Mcc.COM> steve@Pkg.Mcc.COM (Steve Madere) writes: > >What we had to do was to take over the run >operation during display of the MD and refuse >to pass on any events occurring outside the >bounds of the local scene to their targets. > >Ours looks rather kludgey since it requires >finding out what the boundary of the dialog box >is and then checking every event to see if it >occurred within this box. I created a similar class for IV 2.6. The class re-defines the Dialog Accept() member function to filter events but instead of using the boundary, it checks the event target field against each of the interactors within the dialog box. ------------ /* Accept() is the same as for Dialog class except that non-Dialog events are filtered. */ boolean ExclusiveDialog::Accept() { Event e; int v; state->SetValue(0); v = 0; do { Read(e); if (IsTargetInside(e.target, this)) { e.target->Handle(e); }; state->GetValue(v); } while (v == 0 && e.target != nil); return v == 1 || e.target == nil; } /* IsTargetInside() determines whether a given target is the same as the passed interactor i or is contained within i. */ boolean ExclusiveDialog::IsTargetInside(Interactor* target, Interactor* i) { if (i == target) return true; int num; Interactor** intTable; i->GetComponents(0, 0, intTable, num); for(int j = 0; j < num; j++) { if (IsTargetInside(target, intTable[j])) { return true; }; }; if (num) delete [num] intTable; return false; } -------------- If anyone has found a better way, I'd like to hear from you please. Michael Rizzo