zoukankan      html  css  js  c++  java
  • unreal3窗口锁定鼠标开关

    GameViewportClient中有个变量控制是否显示硬件鼠标:

    var transient bool bDisplayHardwareMouseCursor

    也就是系统的光标,一般通过该类中的函数来操纵:

    simulated event SetHardwareMouseCursorVisibility(bool bIsVisible)
    {
        local Vector2D ViewportSize;
        
        //If we are going to be turning on the hardware cursor when it was not already on, we will move the cursor to the middle of the screen
        if (bIsVisible && !bDisplayHardwareMouseCursor)
        {
            GetViewportSize(ViewportSize);
            SetMouse(ViewportSize.X/2,ViewportSize.Y/2);
        }
        bDisplayHardwareMouseCursor = bIsVisible;
    
        ForceUpdateMouseCursor(TRUE);
    }

    其中ForceUpdateMouseCursor是native函数,调用到UGameViewportClient::ForceUpdateMouseCursor,

    在Windows上的实现类为FWindowsViewport,其成员函数

    void FWindowsViewport::UpdateMouseLock( UBOOL bEnforceMouseLockRequestedFlag )

    在每个tick中被调用,会对该控制变量进行检测:

        RECT ClipRect;
        UBOOL bIsHardwareCursorVisible = (GEngine && GEngine->GameViewport && GEngine->GameViewport->bDisplayHardwareMouseCursor);
        UBOOL bIsAnyCursorVisible = bIsSystemCursorVisible || bIsHardwareCursorVisible;
        UBOOL bClipRectValid = (::GetClipCursor( &ClipRect ) != 0);
        UBOOL bHasFocus = HasFocus();
        UBOOL bShouldMouseLock = bEnforceMouseLockRequestedFlag ? bMouseLockRequested : bHasFocus && (IsFullscreen() || !bIsAnyCursorVisible || bMouseLockRequested);

    最后在bShouldMouseLock为TRUE时,调用::ClipCursor锁定鼠标。

  • 相关阅读:
    e.target和e.event和event.srcElement
    js代码优化
    史上最全的CSS hack方式一览
    学习NodeJS第一天:node.js引言
    响应式布局
    HTML+CSS编写规范
    英文SEO外部链接资源收集之常用的footprints
    判别木马
    php简单命令代码集锦
    zencart 新页面调用好功能代码集:
  • 原文地址:https://www.cnblogs.com/wellbye/p/5330020.html
Copyright © 2011-2022 走看看