bool ImageBox::OnInputFromHandler(IInputInjectorPtr injector){ auto ret = __super::OnInputFromHandler(injector); if (ret && mRenderTarget && injector->IsValid(InputDevice::Mouse)){ mRenderTarget->ConsumeInput(injector); } return ret; }
//--------------------------------------------------------------------------- void ConsumeInput(IInputInjectorPtr injector) { if (mOverridingCamera) { mOverridingCamera->ConsumeInput(injector); return; } if (!mCurrentCamera) return; auto target = mTarget.lock(); if (!mProcessInput || !target) return; if (injector->IsValid(InputDevice::Mouse) && !injector->IsKeyDown(VK_CONTROL)){ const Vec3 camPos = GetPosition(); Vec3 toCam = camPos - target->GetPosition(); const Real distToTarget = toCam.Normalize(); long dx, dy; injector->GetDeltaXY(dx, dy); if (injector->IsLButtonDown()) { Real mouseSens = injector->GetSensitivity(); if (dx != 0) { mUserParams.dYaw = dx * mouseSens; } if (dy != 0) { mUserParams.dPitch = -dy * mouseSens; } injector->LockMousePos(true, this); injector->Invalidate(InputDevice::Mouse); } else { //pMouse->LockMousePos(false, this); } long wheel = injector->GetWheel(); if (wheel) { injector->PopWheel(); Real shift = 1.0f; if (injector->IsKeyDown(VK_SHIFT)) shift = 0.1f; Real wheelSens = injector->GetWheelSensitivity(); Real numLinesSens = wheelSens * (Real)injector->GetNumLinesWheelScroll(); numLinesSens *= std::max((Real)1.0f, (Real)(mInternalParams.dist * 0.05f)); mUserParams.dDist += -wheel * numLinesSens * shift; injector->Invalidate(InputDevice::Mouse); } } }
bool TextField::OnInputFromHandler(IInputInjectorPtr injector) { if (!mEnable) return false; bool mouseIn = __super::OnInputFromHandler(injector); if (!mVisibility.IsVisible() || !GetFocus(false)) return mouseIn; if (injector->IsValid(InputDevice::Keyboard)) { auto ch = injector->GetChar(); if (ch == VK_TAB) { if (IsKeyboardFocused()) { auto listbox = IsInListBox(); if (listbox) { injector->PopChar(); if (injector->IsKeyDown(VK_SHIFT)) { listbox->IterateItem(false, true); } else { listbox->IterateItem(true, true); } } else { OnEvent(UIEvents::EVENT_ENTER); } } } else if (ch == VK_RETURN) { bool succ = false; if (OnEvent(UIEvents::EVENT_ENTER)) { succ = true; } else { auto listbox = IsInListBox(); if (listbox) { auto eventHandler = dynamic_cast<EventHandler*>(listbox.get()); if (eventHandler) { if (eventHandler->OnEvent(UIEvents::EVENT_ENTER)) { succ = true; } } } } if (succ) { injector->PopChar(); injector->Invalidate(InputDevice::Keyboard); TriggerRedraw(); } } else if (ch == VK_ESCAPE) { auto prop = IsInPropertyList(); if (prop) { prop->MoveFocusToKeyItem(); injector->PopChar(); injector->Invalidate(InputDevice::Keyboard); } } else { UIManager::GetInstance().GetTextManipulator()->ConsumeInput(injector, mouseIn); } } return mouseIn; }