8000 fix: ctrl-click in mac app and safari didnt open context menu by abose · Pull Request #1994 · phcode-dev/phoenix · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ define(function (require, exports, module) {
// jQuery hides non-left clicks from such event handlers, yet middle-clicks still cause CEF to
// navigate. Also, a capture handler is more reliable than bubble.
window.document.body.addEventListener("click", function (e) {
// Don't interfere with context menu clicks
if (e.button === 2 || (brackets.platform === "mac" && e.ctrlKey)) {
return;
}

// Check parents too, in case link has inline formatting tags
let node = e.target, url;
while (node) {
Expand Down
3 changes: 2 additions & 1 deletion src/project/FileTreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,8 @@ define(function (require, exports, module) {
return;
}

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

Expand Down
10 changes: 9 additions & 1 deletion src/widgets/bootstrap-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,15 @@
* =================================== */

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