Skip to content

Commit d5ef693

Browse files
committed
fix: ctrl-click in mac app and safari didnt open context menu
1 parent b8f5c8a commit d5ef693

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/brackets.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ define(function (require, exports, module) {
470470
// jQuery hides non-left clicks from such event handlers, yet middle-clicks still cause CEF to
471471
// navigate. Also, a capture handler is more reliable than bubble.
472472
window.document.body.addEventListener("click", function (e) {
473+
// Don't interfere with context menu clicks
474+
if (e.button === 2 || (brackets.platform === "mac" && e.ctrlKey)) {
475+
return;
476+
}
477+
473478
// Check parents too, in case link has inline formatting tags
474479
let node = e.target, url;
475480
while (node) {

src/project/FileTreeView.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,8 @@ define(function (require, exports, module) {
835835
return;
836836
}
837837

838-
if (event.button !== LEFT_MOUSE_BUTTON) {
838+
if (event.button !== LEFT_MOUSE_BUTTON
839+
|| (brackets.platform === "mac" && event.ctrlKey)) { // in mac ctrl-click is context menu
839840
return;
840841
}
841842

src/widgets/bootstrap-dropdown.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,15 @@
156156
* =================================== */
157157

158158
$(document)
159-
.on('click.dropdown.data-api', clearMenus)
159+
.on('click.dropdown.data-api', function(e) {
160+
// Don't clear menus if this is a context menu click in mac/safari
161+
// In Chrome, Ctrl+Click = context menu event and doesn't trigger the normal click handlers
162+
// In Safari, Cmd+Click generates both a context menu event AND a regular click event so this check
163+
if (e.button === 2 || (brackets.platform === "mac" && e.ctrlKey)) {
164+
return;
165+
}
166+
clearMenus();
167+
})
160168
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
161169
.on('click.dropdown-menu', function (e) { e.stopPropagation() })
162170
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)

0 commit comments

Comments
 (0)