CefSharp icon indicating copy to clipboard operation
CefSharp copied to clipboard

Mouse pointer disappears use touch mode

Open Jovan-Cheng opened this issue 9 years ago • 10 comments

  • What version of the product are you using?

    • 49.0.1
  • What architecture x86 or x64?

    • Both
  • On what operating system?

    • Win7, Win10
  • Are you using WinForms, WPF or OffScreen?

    • WinForms, WPF
  • What steps will reproduce the problem?

    • Use ChromiumWebBrowser (WinForm) in WindowsFormsHost in a child window (WPF).
    • Open a page(e.g. https://github.com/cefsharp/cefsharp) successfully.
    • Scroll the page use touch mode.
    • Use touch mode to close the child window and return to the parent window.
    • The mouse pointer disappears in the parent window.

Jovan-Cheng avatar Dec 12 '16 09:12 Jovan-Cheng

Is solved,Thx

Jovan-Cheng avatar Dec 14 '16 12:12 Jovan-Cheng

@ccnucheng Can you tell me your solution

e-hai avatar Nov 13 '17 02:11 e-hai

I'm facing the same problem, any suggestions?


What version of the product are you using? 71.0.0

What architecture x86 or x64? x86

On what operating system? Win10

Are you using WinForms, WPF or OffScreen? WinForms in WPF project

TyrWang avatar Mar 11 '19 08:03 TyrWang

https://github.com/cefsharp/CefSharp/issues/1833


发件人: Tyr [email protected] 发送时间: 2019年3月11日 16:34 收件人: cefsharp/CefSharp 抄送: ccnucheng; Mention 主题: Re: [cefsharp/CefSharp] Mouse pointer disappears use touch mode (#1886)

I'm facing the same problem, any suggestions?

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/cefsharp/CefSharp/issues/1886#issuecomment-471448284, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALhG0hkoTmgPDQDxf3Kp_CQo9l2v0Hf0ks5vVhUygaJpZM4LKUOy.

Jovan-Cheng avatar Apr 12 '19 02:04 Jovan-Cheng

That solution didn't work for me.

-What version of the product are you using? 63.0.3 -What architecture x86 or x64? x86 -On what operating system? Win10, Tablet Surface Pro with touch screen and connected keyboard with a touchpad -Are you using WinForms, WPF or OffScreen? WinForms, WPF -Additional information A library WmTouchDevice is used. CefSharp.WinForms in CefWindowsFormsHost.

What steps will reproduce the problem?

Create a main window and a button "Open child window"
Create a child window with Browser and Close button
Run the app, press "Open child window"
Touch somewhere in browser
Touch "Close" button

Result: mouse cursor is invisible in the main window.

Source code files are attached. src.zip

helen-dwa avatar May 07 '19 02:05 helen-dwa

According to my solution, you need to modify the CEF source code


发件人: helen-dwa [email protected] 发送时间: 2019年5月7日 10:41 收件人: cefsharp/CefSharp 抄送: ccnucheng; Mention 主题: Re: [cefsharp/CefSharp] Mouse pointer disappears use touch mode (#1886)

That solution didn't work for me.

-What version of the product are you using? 63.0.3 -What architecture x86 or x64? x86 -On what operating system? Win10, Tablet Surface Pro with touch screen and connected keyboard with a touchpad -Are you using WinForms, WPF or OffScreen? WinForms, WPF -Additional information A library WmTouchDevice is used. CefSharp.WinForms in CefWindowsFormsHost.

What steps will reproduce the problem?

Create a main window and a button "Open child window" Create a child window with Browser and Close button Run the app, press "Open child window" Touch somewhere in browser Touch "Close" button

Result: mouse cursor is invisible in the main window.

Source code files are attached. src.ziphttps://github.com/cefsharp/CefSharp/files/3150581/src.zip

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/cefsharp/CefSharp/issues/1886#issuecomment-489885177, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AC4ENUVBL5DCGM2PCSB6HFTPUDT65ANCNFSM4CZJIOZA.

Jovan-Cheng avatar May 16 '19 07:05 Jovan-Cheng

How exactly to modify?

helen-dwa avatar May 16 '19 23:05 helen-dwa

hi @ccnucheng are you able to help with the required code that was changed to solve this - we are seeing the same issue many thanks in advance thanks

darrenahunter avatar Jul 15 '19 04:07 darrenahunter

Here is what is causing the problem:

The Cef Browser is hiding the Cursor when a touch event occurs.

Add the following code to you host form on load event:

    MouseEnter += (o, mE) => Cursor.Show();
    MouseLeave += (o, mE) => Cursor.Show();

This will ensure the cursor is reset to visible.

NOTE: In our solution we are using DockStyle.Fill. So attaching to Form works well. If you are not using Fill you may want to attach the MouseEnter/MouseExit to you browser Container.

NOTE: I have tried attaching these events to the Cef control itself and they do not trigger !

evelo2 avatar Jul 26 '19 16:07 evelo2

    MouseEnter += (o, mE) => Cursor.Show();
    MouseLeave += (o, mE) => Cursor.Show();

Thank you. This solution worked well in a project of the "application" type (produces .exe file). It was not working in the dll module project. I have another solution.

// class to fix the bug: mouse cursor disappears if to close CEF browser by touch
    public class CefTouchShowCursor
    {
        [DllImport("User32.dll")]
        private static extern int ShowCursor(bool bShow);
        [DllImport("user32.dll")]
        static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName);
        [DllImport("user32.dll")]
        public static extern IntPtr SetCursor(IntPtr handle);

        public static void ShowCursor()
        {
            IntPtr handle = LoadCursor(IntPtr.Zero, 32649); // 32649 - "arrow", 32512 - "handle" mouse pointer
            SetCursor(handle);
            ShowCursor(true);
        }
    }

helen-dwa avatar Jul 29 '19 00:07 helen-dwa