bool TrySetMouseOver(ISelectable selection, RayQueryResult?ray) { //validate if (selection == _mouseOver) { if (selection == null || !selection.SelectSubObject() || (ray != null && _mouseOverArg != null && _mouseOverArg.SubObject == ray.Value.SubObject)) { return(false); } } var e = new MouseSelectingArgs() { Ray = ray }; if (ray.HasValue) { e.SubObject = ray.Value.SubObject; } //fire events _mouseOver?.MouseExited(); _mouseOver = selection; _mouseOverArg = e; _mouseOver?.MouseEntered(e); return(true); }
bool TrySetSelection(ISelectable selection, RayQueryResult?ray) { //validate if (selection == _selection) { if (selection == null || !selection.SelectSubObject() || (ray != null && _selectionArg != null && _selectionArg.SubObject == ray.Value.SubObject)) { return(false); } } //see if selectable is OK with selection var e = new MouseSelectingArgs() { Ray = ray }; if (ray.HasValue) { e.SubObject = ray.Value.SubObject; } selection?.MouseSelecting(e); if (!e.Select) //selection not allowed { return(false); } //fire selection events _selection?.MouseUnselected(); _selectionArg = e; var prevSelection = _selection; _selection = selection; //swap inputReceivers var inputReceiver = prevSelection as IInputReceiver; if (inputReceiver != null) { _inputManager.Remove(inputReceiver); } inputReceiver = _selection as IInputReceiver; if (inputReceiver != null) { _inputManager.Add(inputReceiver); } //request excusive mouse access while selected _inputPermissions.RequestExclusiveMouse = _selection != null; return(true); }