How to hide the cursor in Awesomium

前端 未结 1 974
隐瞒了意图╮
隐瞒了意图╮ 2021-01-23 17:04

I tried this:


but the cursor still shows.

相关标签:
1条回答
  • 2021-01-23 17:36

    You can use a ResouceInterceptor and manipulate the page on the fly to insert custom CSS.

    EDIT:

    The following implementation should do the job. (It assumes there is a text.css file)

    class ManipulatingResourceInterceptor : IResourceInterceptor
    {
        public ResourceResponse OnRequest(ResourceRequest request)
        {
            Stream stream = null;
    
            //do stream manipulation
            if (request.Url.ToString() == "http://your.web.url/test.css")
            {
                WebRequest myRequest;
                myRequest = WebRequest.Create(request.Url);
                Stream webStream = myRequest.GetResponse().GetResponseStream();
                StreamReader webStreamReader = new StreamReader(webStream);
                string webStreamContent = webStreamReader.ReadToEnd();
    
                stream = webStream;
    
                string extraContent = "*{cursor: none;}";
    
                webStreamContent += extraContent;
                byte[] responseBuffer = Encoding.UTF8.GetBytes(webStreamContent);
    
                // Initialize unmanaged memory to hold the array.
                int responseSize = Marshal.SizeOf(responseBuffer[0]) * responseBuffer.Length;
                IntPtr pointer = Marshal.AllocHGlobal(responseSize);
                try
                {
                    // Copy the array to unmanaged memory.
                    Marshal.Copy(responseBuffer, 0, pointer, responseBuffer.Length);
                    return ResourceResponse.Create((uint)responseBuffer.Length, pointer, "text/css");
                }
                finally
                {
                    // Data is not owned by the ResourceResponse. A copy is made 
                    // of the supplied buffer. We can safely free the unmanaged memory.
                    Marshal.FreeHGlobal(pointer);
                    stream.Close();
                }
            }
            return null;
        }
    
        public bool OnFilterNavigation(NavigationRequest request)
        {
            return false;
        }
    }
    
    0 讨论(0)
提交回复
热议问题