scroll bars not working in cefclient sample app?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

scroll bars not working in cefclient sample app?

Postby michaeladamkatz » Wed Jan 09, 2013 9:28 pm

Out of the box, when I build and run the cefclient example, and browse to a page that more than fills the window size, scroll bars appear along the right and bottom of the window, as expected. But clicking on them (on the bars, on the gray space behind the bars, or on the arrows at either end) does nothing. I can use the arrow keys to slide the page around, and the scroll bars follow along, but they seem to be "read only".

I'm mainly trying to understand if this is just a problem in the cefclient event handling, or something deeper.
michaeladamkatz
Mentor
 
Posts: 50
Joined: Wed Jan 09, 2013 5:10 pm

Re: scroll bars not working in cefclient sample app?

Postby magreenblatt » Wed Jan 09, 2013 9:31 pm

What OS and CEF version? What URL?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: scroll bars not working in cefclient sample app?

Postby michaeladamkatz » Wed Jan 09, 2013 9:40 pm

Thanks for the quick reply. I now believe this might be a problem in my own web code. Sorry for the false alarm. I'll post again if I learn something that might be useful to others...
michaeladamkatz
Mentor
 
Posts: 50
Joined: Wed Jan 09, 2013 5:10 pm

Re: scroll bars not working in cefclient sample app?

Postby michaeladamkatz » Wed Jan 09, 2013 11:37 pm

I figured it out. On the chance it may be useful to some, here's what was happening.

Because my app is a "web app" and wants to behave mostly like a normal app and not like a typical web page, I use a JQuery mousedown handler to prevent arbitrary drag selection on the page. I do want *certain* areas of the page to be selectable, but for instance I don't want my row of toolbar icons to be selectable, and in general I don't want the various widgets making up my page to be selectable.

So, in this mousedown handler I was checking if the mouse was over various selectable areas on the page, and if so I returned true, else I returned false, the latter having the effect of swallowing the mouse event and thus disabling selection except where allowed.

The surprise was that Chrome/Chromium/CEF treats this a bit differently than Firefox. In Firefox, if the mousedown handler returns false, it will still process mouse events on the browser scroll bars correctly. In Chrome/Chromium/CEF that false eats the event even for the scroll bars.

The solution is to check if the mousedown is on one of the window scroll bars, and return true in that case. I wasn't able to find a way to check for the scroll bars directly, but I found that when the scroll bars are shown the area they cover is considered to be "outside" the window content, at least in Chrome/Chromium/CEF.

Adding the if below "process scroll bars normally" fixed things.

Code: Select all
function HandleJQueryMouseDown( e )
{
   // not shown: checks for various selectable mouse down areas, which return true

   // process scroll bars normally
   if ( e.pageX > ( $( window ).scrollLeft() + $( window ).width() ) ||
             e.pageY > ( $( window ).scrollTop() + $( window ).height() ) )
   {
      return true;
   }
   
   // the following false prevents arbitrary selection on the page
   
   return false;
}
michaeladamkatz
Mentor
 
Posts: 50
Joined: Wed Jan 09, 2013 5:10 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 202 guests