unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Simulating mouse-clicks
@ 2021-09-18 21:54 Ag Ibragimov
  2021-09-19 18:30 ` Zhiwei Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Ag Ibragimov @ 2021-09-18 21:54 UTC (permalink / raw)
  To: emacs-devel

Can someone share an example, Emacs Lisp snippet where mouse-click gets
simulated, e.g., programmatically clicking mouse-1 in current window. I
can't figure this out. Thanks!

--
Thanks,
Ag



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Simulating mouse-clicks
  2021-09-18 21:54 Simulating mouse-clicks Ag Ibragimov
@ 2021-09-19 18:30 ` Zhiwei Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Zhiwei Chen @ 2021-09-19 18:30 UTC (permalink / raw)
  To: Ag Ibragimov; +Cc: emacs-devel

Ag Ibragimov <agzam.ibragimov@gmail.com> writes:

> Can someone share an example, Emacs Lisp snippet where mouse-click gets
> simulated, e.g., programmatically clicking mouse-1 in current window. I
> can't figure this out. Thanks!

#+begin_src elisp
(defun left-is-clicked ()
  (interactive)
  (message "mouse left button is clicked"))
(global-set-key (kbd "<mouse-1>") #'left-is-clicked)

(defun simulate-left-click ()
  (interactive)
  (push '(t . mouse-1) unread-command-events))
(global-set-key (kbd "C-c d") #'simulate-left-click)
#+end_src

Press C-c d to see the result, bro.

-- 
Zhiwei Chen



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-19 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18 21:54 Simulating mouse-clicks Ag Ibragimov
2021-09-19 18:30 ` Zhiwei Chen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).