Mercurial > emacs
changeset 75375:2d3bcf670390
(mac-keyboard-modifier-mask-alist): New constant.
(mac-ae-keyboard-modifiers): New function.
(mac-handle-toolbar-switch-mode): Use it.
(mac-dnd-handle-drag-n-drop-event): Likewise. Set action to `copy'
if keyboard modifiers on drop contain option key.
(mac-dnd-drop-data): Add optional argument `action'.
(special-event-map): Remove binding for M-drag-n-drop.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Mon, 22 Jan 2007 08:27:23 +0000 |
parents | 833f47947882 |
children | 7b70538ea11c |
files | lisp/term/mac-win.el |
diffstat | 1 files changed, 31 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/term/mac-win.el Mon Jan 22 07:14:15 2007 +0000 +++ b/lisp/term/mac-win.el Mon Jan 22 08:27:23 2007 +0000 @@ -1687,6 +1687,26 @@ (+ (* i 10) 12))))) result)) +(defconst mac-keyboard-modifier-mask-alist + (mapcar + (lambda (modifier-bit) + (cons (car modifier-bit) (lsh 1 (cdr modifier-bit)))) + '((command . 8) ; cmdKeyBit + (shift . 9) ; shiftKeyBit + (option . 11) ; optionKeyBit + (control . 12) ; controlKeyBit + (function . 17))) ; kEventKeyModifierFnBit + "Alist of Mac keyboard modifier symbols vs masks.") + +(defun mac-ae-keyboard-modifiers (ae) + (let ((modifiers-value (mac-ae-number ae "kmod")) + modifiers) + (if modifiers-value + (dolist (modifier-mask mac-keyboard-modifier-mask-alist) + (if (/= (logand modifiers-value (cdr modifier-mask)) 0) + (setq modifiers (cons (car modifier-mask) modifiers))))) + modifiers)) + (defun mac-ae-open-documents (event) "Open the documents specified by the Apple event EVENT." (interactive "e") @@ -1762,9 +1782,8 @@ frame where the tool-bar toggle button was pressed. With some modifiers, it changes global tool-bar visibility setting." (interactive "e") - (let* ((ae (mac-event-ae event)) - (modifiers (cdr (mac-ae-parameter ae "kmod")))) - (if (and modifiers (not (string= modifiers "\000\000\000\000"))) + (let ((ae (mac-event-ae event))) + (if (mac-ae-keyboard-modifiers ae) ;; Globally toggle tool-bar-mode if some modifier key is pressed. (tool-bar-mode) (let ((frame (mac-ae-frame ae))) @@ -2221,10 +2240,10 @@ (defun mac-dnd-insert-TIFF (window action data) (dnd-insert-text window action (mac-TIFF-to-string data))) -(defun mac-dnd-drop-data (event frame window data type) +(defun mac-dnd-drop-data (event frame window data type &optional action) + (or action (setq action 'private)) (let* ((type-info (assoc type mac-dnd-types-alist)) (handler (cdr type-info)) - (action 'private) (w (posn-window (event-start event)))) (when handler (if (and (windowp w) (window-live-p w) @@ -2245,12 +2264,16 @@ (defun mac-dnd-handle-drag-n-drop-event (event) "Receive drag and drop events." (interactive "e") - (let ((window (posn-window (event-start event)))) + (let ((window (posn-window (event-start event))) + (ae (mac-event-ae event)) + action) (when (windowp window) (select-window window)) - (dolist (item (mac-ae-list (mac-event-ae event))) + (if (memq 'option (mac-ae-keyboard-modifiers ae)) + (setq action 'copy)) + (dolist (item (mac-ae-list ae)) (if (not (equal (car item) "null")) (mac-dnd-drop-data event (selected-frame) window - (cdr item) (car item))))) + (cdr item) (car item) action)))) (select-frame-set-input-focus (selected-frame))) ;;; Do the actual Windows setup here; the above code just defines @@ -2591,7 +2614,6 @@ ;; Initiate drag and drop (define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event) -(define-key special-event-map [M-drag-n-drop] 'mac-dnd-handle-drag-n-drop-event) ;;;; Non-toolkit Scroll bars