From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felix Dietrich Newsgroups: gmane.emacs.help Subject: Re: How to create SVG image as clickable button? Date: Sun, 25 Sep 2022 11:01:23 +0200 Message-ID: <87leq7bzfg.fsf@sperrhaken.name> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40665"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) Cc: Help GNU Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 25 11:05:00 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocNZL-000AKq-Cs for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 25 Sep 2022 11:04:59 +0200 Original-Received: from localhost ([::1]:58268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocNZK-0002Hp-88 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 25 Sep 2022 05:04:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocNWY-0002F3-LC for help-gnu-emacs@gnu.org; Sun, 25 Sep 2022 05:02:06 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.131]:51265) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocNWX-0002Eu-0U for help-gnu-emacs@gnu.org; Sun, 25 Sep 2022 05:02:06 -0400 Original-Received: from localhost ([77.13.104.186]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MEmIl-1oSDQp2dJL-00GJ58; Sun, 25 Sep 2022 11:01:28 +0200 In-Reply-To: (Jean Louis's message of "Sun, 25 Sep 2022 00:46:37 +0300") X-Provags-ID: V03:K1:2utK5hT4KZMcGse3YA0zuy4mOSmxAMpTPTFjA5+JMayZYL4Xq05 qXjY+HtkUG4KV6TLFic5uCQ7cvdgp1uEkdMPTWAVrOMWGGb/yITY3tYRJuYUA+111Kgx4EJ KyeBeOAjvhhWCjDltgtCXvuClsWytPNDSwz7Qh8KsFVnpixz+noNw6EmIgmNh2iaSDs39JV 2/E/7IEMlxCnLWNvIP7lg== X-UI-Out-Filterresults: notjunk:1;V03:K0:tEe3XGUdMOE=:E72wDa2R/V0MyB+g4teFHr erysZsM4re93ORwfQFt/1NmjvNwhn3hkS1nHHuYvtYKenO9AW0ExnhCIaGGZEbEmQI/M6qHo3 M9BERdTl2MuAYKrr7JzIINlaXxxulrOGa4rPn9DMjFPAm3mR7adTxI1Afo7Fqv9I30/7EyK2i f3AYWPz0JzA2qjnxxV5pG6LmO0s4+Tnii6MSBleMmtrg/wu7anIHfmz7n0XHpAOWxb6NzagtO EDWn0c6MQu2dLPO5uy4WWwLWhKLgFM3t3EKvkFppGXvusyRP1PY7XycJmSVRct5lOxZa401lo VF5cLS0jKFIv5Q9PP42mHG+qe9b9JJngjUQzfI7gFRtWd5sIb4d76EVhk+Lam2LeddEkZYJ+B dWd9AbLwCrv07CeW4EVU4ipwAyUK+TYAVtzX3h6jFwqmZ6vHAnFS2V2erBjkGGCA9vpt2kDlm IXaCkDqGqSL3cRLhTXeocbLL8A/M+j2KnCA+nB6o3395FcQxZFz+j9kbVrCeiuLcztJ9osdnO mT9Wxh2jIyRD0KDkGm5QbgxBYrTxIHf8OiM3ez5AkIqfHIp3Ob6RdfA4a72fGI7DWBIbhppyC D7Iel4biIHWbzB+m06YbRExWA5JqniUOxLkSqCKafZGIzPLN2R6DGo8H22MJi+gDt5k/FQjxP 9wIPdWH3XIP/cql5bzoG2WQTE8uvRXLjD/X0DEW+OTzJw+DDn4q36/jCDfLoIOu757BT5nv3w IQ91TpFig5+T6JALCWqWCwhNYWrmRKs0XjIpcJZ/Tnu4nokXkIDqE/Wv1/wVkmvDcufbMwH4 Received-SPF: none client-ip=212.227.126.131; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:139623 Archived-At: Hello Jean Louis, Jean Louis writes: > I am now here, trying to make image as clickable button, need help > please. > > (let ((image (create-image "/home/data1/protected/Programming/git/haiku-i= cons/png/64x64/Alert_Info.png" > nil nil :action 'my-function))) > (insert-image image)) in the documentation for Emacs 28.1, I cannot find an image property :action. For buttons, though, I can find a property =E2=80=98action=E2=80= =99. Note that there is no colon in front of =E2=80=98action=E2=80=99: it is not a ke= yword symbol but a proper one. With the following snippet, I managed to insert a clickable image button at the end of the current buffer: #+begin_src emacs-lisp (save-excursion (goto-char (point-max)) (let* ((path "path/to/image") (image (create-image path))) ;; (insert-button (propertize " " 'display image) ;; 'action =E2=80=A6 (insert-button " " 'display image 'action (lambda (button) (message "Button clicked"))))) #+end_src You could also try to insert an image with custom keybindings: #+begin_src emacs-lisp (save-excursion (let* ((start (point)) (keymap (let ((map (make-sparse-keymap))) ;; The default keymap for images inserted with ;; =E2=80=98insert-image=E2=80=99 is =E2=80=98image-ma= p=E2=80=99. It is a global ;; variable. (set-keymap-parent map image-map) (define-key map [mouse-1] (lambda () (interactive) (message "Hello World from mouse click!"))) (define-key map [?h] (lambda () (interactive) (message "Hello World from key press!"))) map)) (path "path/to/image") (image (create-image path))) =20=20 (goto-char (point-max)) (insert-image image) (add-text-properties start (point) `(keymap ,keymap)))) #+end_src --=20 Felix Dietrich