conflict with defined touch screen gestures (such as ``long-press to
drag''), or with user expectations for touch input, and shouldn't
subject the touch sequence to simple translation. If a command whose
-name contains the property @code{ignored-mouse-command} is encountered
-or there is no command bound to @code{down-mouse-1}, a more irregular
-form of translation takes place: here, Emacs processes touch screen
-gestures (@pxref{Touchscreens,,, emacs, The GNU Emacs Manual}) first,
-and finally attempts to translate touch screen events into mouse
-events if no gesture was detected prior to a closing
-@code{touchscreen-end} event and a command is bound to @code{mouse-1}
-at the location of that event. Before generating the @code{mouse-1}
-event, point is also set to the location of the @code{touchscreen-end}
-event, and the window containing the position of that event is
-selected, as a compromise for packages which assume
-@code{mouse-drag-region} has already set point to the location of any
-mouse click and selected the window where it took place.
+name contains the property (@pxref{Symbol Properties})
+@code{ignored-mouse-command} is encountered or there is no command
+bound to @code{down-mouse-1}, a more irregular form of translation
+takes place: here, Emacs processes touch screen gestures
+(@pxref{Touchscreens,,, emacs, The GNU Emacs Manual}) first, and
+finally attempts to translate touch screen events into mouse events if
+no gesture was detected prior to a closing @code{touchscreen-end}
+event and a command is bound to @code{mouse-1} at the location of that
+event. Before generating the @code{mouse-1} event, point is also set
+to the location of the @code{touchscreen-end} event, and the window
+containing the position of that event is selected, as a compromise for
+packages which assume @code{mouse-drag-region} has already set point
+to the location of any mouse click and selected the window where it
+took place.
To prevent unwanted @code{mouse-1} events arriving after a mouse menu
is dismissed (@pxref{Mouse Menus}), Emacs also avoids simple
starting position of the touch sequence, consequentially displaying
the mouse menu.
+@cindex @code{mouse-1-menu-command}, a symbol property
+Since certain commands are also bound to @code{down-mouse-1} for the
+purpose of displaying pop-up menus, Emacs additionally behaves as
+illustrated in the last paragraph if @code{down-mouse-1} is bound to a
+command whose name has the property @code{mouse-1-menu-command}.
+
+@cindex touchscreen gesture events
If touch gestures are detected during translation, one of the
following input events may be generated:
\f
;; Provide a mode-specific menu on a mouse button.
-(defun minor-mode-menu-from-indicator (indicator)
+(defun minor-mode-menu-from-indicator (indicator &optional event)
"Show menu for minor mode specified by INDICATOR.
+EVENT may be the mouse event that is causing this menu to be
+displayed.
+
Interactively, INDICATOR is read using completion.
If there is no menu defined for the minor mode, then create one with
items `Turn Off' and `Help'."
,(lambda () (interactive)
(describe-function mm-fun)))))))
(if menu
- (popup-menu menu)
+ (popup-menu menu event)
(message "No menu available")))))
(defun mouse-minor-mode-menu (event)
"Show minor-mode menu for EVENT on minor modes area of the mode line."
(interactive "@e")
(let ((indicator (car (nth 4 (car (cdr event))))))
- (minor-mode-menu-from-indicator indicator)))
+ (minor-mode-menu-from-indicator indicator event)))
+
+;; See (elisp)Touchscreen Events.
+(put 'mouse-minor-mode-menu 'mouse-1-menu-command t)
(defun mouse-menu-major-mode-map ()
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
(if interactive
;; Called interactively (probably from wid-edit.el.)
;; Add any event generated to `unread-command-events'.
- (let ((event (catch 'input-event
- (touch-screen-translate-touch nil) nil)))
- (when (vectorp event)
+ (let ((event1
+ (let ((current-key-remap-sequence (vector event)))
+ (touch-screen-translate-touch nil))))
+ (when (vectorp event1)
(setq unread-command-events
(nconc unread-command-events
- (nreverse (append event nil))))))
+ (nreverse (append event1 nil))))))
(cond
((eq (car event) 'touchscreen-begin)
;; A tool was just pressed against the screen. Figure out the
t nil position))
(not (and (symbolp binding)
(get binding 'ignored-mouse-command))))))
- (if (keymapp binding)
- ;; binding is a keymap. If a `mouse-1' event is
- ;; generated after the keyboard command loop displays
- ;; it as a menu, that event could cause unwanted
- ;; commands to be run. Set what to `mouse-1-menu'
- ;; instead and wait for the up event to display the
- ;; menu.
+ (if (or (keymapp binding)
+ (and (symbolp binding)
+ (get binding 'mouse-1-menu-command)))
+ ;; binding is a keymap, or a command that does almost
+ ;; the same thing. If a `mouse-1' event is generated
+ ;; after the keyboard command loop displays it as a
+ ;; menu, that event could cause unwanted commands to
+ ;; be run. Set what to `mouse-1-menu' instead and
+ ;; wait for the up event to display the menu.
(setcar (nthcdr 3 touch-screen-current-tool)
'mouse-1-menu)
(progn (setcar (nthcdr 3 touch-screen-current-tool)