Feature/dragjs #231

Closed
wants to merge 15 commits into
from

Projects

None yet

4 participants

@clintberry
Contributor

This adds the ability to create a mousedown event in the DOM that will drag the shell window around the screen. Convenient if you remove the frame from CEF and need a way to move the window around still.

@gruehle gruehle and 1 other commented on an outdated diff May 9, 2013
appshell/appshell_extensions.cpp
@@ -580,7 +580,21 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
responseArgs->SetString(2, parentId);
responseArgs->SetInt(3, index);
}
- } else {
+ } else if (message_name == "Drag") {
@gruehle
gruehle May 9, 2013 Member

The name "Drag" is a bit too generic. "DragWindow" would be better.

@clintberry
clintberry May 9, 2013 Contributor

Sounds good, I will update.

@gruehle gruehle commented on an outdated diff May 9, 2013
appshell/appshell_extensions.cpp
@@ -580,7 +580,21 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
responseArgs->SetString(2, parentId);
responseArgs->SetInt(3, index);
}
- } else {
+ } else if (message_name == "Drag") {
+ // Parameters:
+ // 0: int32 - callback id
@gruehle
gruehle May 9, 2013 Member

This comment is out of date. Please update or remove.

@gruehle gruehle commented on an outdated diff May 9, 2013
appshell/appshell_extensions.js
@@ -687,6 +687,19 @@ if (!appshell.app) {
appshell.app.showExtensionsFolder = function (appURL, callback) {
appshell.app.showOSFolder(GetApplicationSupportDirectory() + "/extensions", callback);
};
+
+ /**
+ * Open the extensions folder in an OS file window.
@gruehle
gruehle May 9, 2013 Member

This comment block needs updating.

@gruehle gruehle commented on an outdated diff May 9, 2013
appshell/appshell_extensions.js
@@ -687,6 +687,19 @@ if (!appshell.app) {
appshell.app.showExtensionsFolder = function (appURL, callback) {
appshell.app.showOSFolder(GetApplicationSupportDirectory() + "/extensions", callback);
};
+
+ /**
+ * Open the extensions folder in an OS file window.
+ *
+ * @param {string} appURL Not used
+ * @param {function(err)} callback Asynchronous callback function with one argument (the error)
+ *
+ * @return None. This is an asynchronous call that sends all return information to the callback.
+ */
+ native function Drag();
+ appshell.app.drag = function () {
@gruehle
gruehle May 9, 2013 Member

Again, "drag" is a bit too generic. This should be "dragWindow".

@gruehle gruehle commented on an outdated diff May 9, 2013
appshell/appshell_extensions_mac.mm
@@ -1001,3 +1001,24 @@ int32 RemoveMenuItem(CefRefPtr<CefBrowser> browser, const ExtensionString& comma
return NO_ERROR;
}
+
+void Drag(CefRefPtr<CefBrowser> browser)
+{
+ NSWindow* win = [browser->GetHost()->GetWindowHandle() window];
+ NSPoint origin = [win frame].origin;
+ NSPoint current = [NSEvent mouseLocation];
+ NSPoint offset;
+ origin.x -= current.x;
+ origin.y -= current.y;
+
+ while (YES) {
+ NSEvent* event = [win nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask)];
@gruehle
gruehle May 9, 2013 Member

Style nit: this block of code should be indented by 4 spaces instead of 2.

@gruehle
Member
gruehle commented May 9, 2013

@clintberry - sorry it's taken so long to review. The code works great on Mac and Windows, I just had a few small comments.

Also, it would be best if you could squash/rebase your commits. Thanks!

@clintberry
Contributor

Nice! okay, I have never rebased before. I will give it a go now...

@clintberry
Contributor

I'm not sure why that last merge got in there. Still learning Git, sorry. But I did clean up the code. Sorry it was so messy. I will make sure to clean up comments and styling better next time. Working on getting the chrome frame transparent so you can make apps with all sorts of shapes :-)

@gruehle
Member
gruehle commented May 9, 2013

Thanks! I rebased/squashed your commits into 5e52d86 and merged.

@gruehle gruehle closed this May 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment