Frameless JFrame with HTML Element Who Can Drag the Window

Having problems with building or using the JCEF Java binding? Ask your questions here.

Frameless JFrame with HTML Element Who Can Drag the Window

Postby kevinfaguiar » Sun May 28, 2017 12:01 pm

Hi guys,

I'm having some problem using JCEF with a "frameless JFrame", this is, without the Window menu who includes close and minimize button. I've implemented a way of closing and minimizing the Jframe with cefQuery on click of a HTML Button element, like this:
Code: Select all
$('#close-window').on('click', function() {
           window.cefQuery({
             request: 'CLOSE',
             onSuccess: function(response) {
               console.log('Response: '+response);
             },
             onFailure: function(error_code, error_message) {}
           });
      });

In this case, I utilize a MessageHandler to receive the "CLOSE" string, and then, in Java, I close the Jframe.

My doubt, however, rests in how can I make a HTML element, like a div, to be draggable and then, drag all the Window (by consequence, the Jframe) around, like if I dragged the JFrame top frame.

After some research, i've come across this implementation of DragHandler on CEFSharp:
Code: Select all
  virtual bool OnDragEnter(CefRefPtr<CefBrowser> browser,
                           CefRefPtr<CefDragData> dragData,
                           CefRefPtr<CefDragData> dragData,
                           DragOperationsMask mask) { return false; }
                           DragOperationsMask mask) { return false; }

  ///
  // Called whenever draggable regions for the browser window change. These can
  // be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If
  // draggable regions are never defined in a document this method will also
  // never be called. If the last draggable region is removed from a document
  // this method will be called with an empty vector.
  ///
  /*--cef()--*/
  virtual void OnDraggableRegionsChanged(
      CefRefPtr<CefBrowser> browser,
      const std::vector<CefDraggableRegion>& regions) {}
};
};

However, as many knows, in Java CEF we only have the method OnDragEnter, and not the OnDraggableRegionsChanged. So, my question is: there is a way for me to make a DIV HTML element, who, on drag, drag the Jframe around? Or a implementation like that from CEFSharp, where you simply put a '-webkit-app-region: drag/no-drag' CSS-property and it drags the frame?
kevinfaguiar
Newbie
 
Posts: 2
Joined: Sun May 28, 2017 11:43 am

Re: Frameless JFrame with HTML Element Who Can Drag the Wind

Postby magreenblatt » Mon May 29, 2017 6:21 am

You can expose OnDraggableRegionsChanged in JCEF. PRs welcome.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Frameless JFrame with HTML Element Who Can Drag the Wind

Postby kevinfaguiar » Tue May 30, 2017 10:05 am

Do you have an example how to expose? I'm sorry, i'm really newbie on working with Chromium...
kevinfaguiar
Newbie
 
Posts: 2
Joined: Sun May 28, 2017 11:43 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 18 guests