unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eduardo Ochs <eduardoochs@gmail.com>
To: Heime <heimeborgia@protonmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Mouse activated button in modeline
Date: Sun, 21 Jul 2024 22:46:35 -0300	[thread overview]
Message-ID: <CADs++6iGUvvehgWgMxVTHgc1A4Sh+YowJkpGQDHO0nsuwRDk8w@mail.gmail.com> (raw)
In-Reply-To: <10DZZ3c_ssrHn8C6ULFl21Gjy5bHodK7L5A5SGPGeynF7sAT7r0rhcXzn0wQ2ojWizyEdWd1fSZT0S-HFQxPCDDvKPYvnygRKEmnLPzOF9g=@protonmail.com>

Here my mode line says

  U:**-  TODO           Bot L122542  (Fundamental eev)

and when I hover the mouse over the first "*" it says:

  Buffer is writable
  mouse-1: toggle

Cheers,
  Eduardo Ochs
  http://anggtwu.net/#eev



On Sun, 21 Jul 2024 at 16:53, Heime <heimeborgia@protonmail.com> wrote:

> On Monday, July 22nd, 2024 at 6:15 AM, Heime <heimeborgia@protonmail.com>
> wrote:
>
> > I would like to have a button in modeline I can mouse click to toggle
> the file to read-only on-off.
>
> Why does the following not show the mouse activated button
>
> (defface mode-line-read-only-face
>   '((t :background "red" :foreground "white" :weight bold)))
>
> (defun toggle-read-only-status ()
>   (interactive)
>   (if buffer-read-only
>        (read-only-mode -1)
>     (read-only-mode 1)))
>
> (defun read-only-button ()
>   (if buffer-read-only
>        (propertize " RO "
>          'face 'mode-line-read-only-face
>          'help-echo "Read-Only Buffer - Click to toggle."
>          'mouse-face 'mode-line-highlight
>          'local-map (make-mode-line-mouse-map
>                       'mouse-1 'toggle-read-only-status))
>
>     (propertize " -- "
>       'help-echo "Writable Buffer - Click to toggle."
>       'mouse-face 'mode-line-highlight
>       'local-map (make-mode-line-mouse-map
>                    'mouse-1 'toggle-read-only-status))))
>
> (setq-default mode-line-format
>   '("%e" '(:eval (read-only-button)) ""))
>
>
>
>
>


      reply	other threads:[~2024-07-22  1:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-21 18:15 Mouse activated button in modeline Heime
2024-07-21 19:52 ` Heime
2024-07-22  1:46   ` Eduardo Ochs [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=CADs++6iGUvvehgWgMxVTHgc1A4Sh+YowJkpGQDHO0nsuwRDk8w@mail.gmail.com \
    --to=eduardoochs@gmail.com \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@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.
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).