all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Mouse activated button in modeline
@ 2024-07-21 18:15 Heime
  2024-07-21 19:52 ` Heime
  0 siblings, 1 reply; 3+ messages in thread
From: Heime @ 2024-07-21 18:15 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I would like to have a button in modeline I can mouse click to toggle the file to read-only on-off.




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

* Re: Mouse activated button in modeline
  2024-07-21 18:15 Mouse activated button in modeline Heime
@ 2024-07-21 19:52 ` Heime
  2024-07-22  1:46   ` Eduardo Ochs
  0 siblings, 1 reply; 3+ messages in thread
From: Heime @ 2024-07-21 19:52 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

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)) ""))






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

* Re: Mouse activated button in modeline
  2024-07-21 19:52 ` Heime
@ 2024-07-22  1:46   ` Eduardo Ochs
  0 siblings, 0 replies; 3+ messages in thread
From: Eduardo Ochs @ 2024-07-22  1:46 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

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)) ""))
>
>
>
>
>


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

end of thread, other threads:[~2024-07-22  1:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-21 18:15 Mouse activated button in modeline Heime
2024-07-21 19:52 ` Heime
2024-07-22  1:46   ` Eduardo Ochs

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.