0

I'm trying to have a clickable button in the header-line. The code below works for the mode-line but not for the header line. Is there something specific to add?

(setq-default header-line-format
 (list `(:propertize " ☰ "
                    face       mode-line-mode
                    mouse-face mode-line-highlight
                    local-map  ,mode-line-major-mode-keymap)
       `(:propertize "%m " face mode-line)))
2

A click on the mode-line does not generate the event sequence [mouse-1] but [mode-line mouse-1] and similarly a click on the header line generates the sequence [header-line mouse-1], so you need to tweak the mode-line-major-mode-keymap so it also reacts to event sequences like [header-line mouse-1]. For example with:

(define-key mode-line-major-mode-keymap [header-line]
            (lookup-key mode-line-major-mode-keymap [mode-line]))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.