unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Zhiwei Chen <condy0919@gmail.com>
To: Ag Ibragimov <agzam.ibragimov@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Simulating mouse-clicks
Date: Mon, 20 Sep 2021 02:30:28 +0800	[thread overview]
Message-ID: <87wnnccta3.fsf@gmail.com> (raw)
In-Reply-To: <m2a6k9o8bl.fsf@gmail.com> (Ag Ibragimov's message of "Sat, 18 Sep 2021 16:54:00 -0500")

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



      reply	other threads:[~2021-09-19 18:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-18 21:54 Simulating mouse-clicks Ag Ibragimov
2021-09-19 18:30 ` Zhiwei Chen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnnccta3.fsf@gmail.com \
    --to=condy0919@gmail.com \
    --cc=agzam.ibragimov@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).