Subject: bug#12817: 24.2; The button library does not work on the header line

From: Damien Cassou <[email-masked]>
Date: Thu, 6 Dec 2012 08:38:01 +0100

Thank you very much Jonas

Damien Cassou
http://damiencassou.seasidehosting.st
On Dec 5, 2012 9:39 PM, "Jonas Bernoulli" <[email-masked]> wrote:

> The attached patch allows inserting buttons into the header-line as well
> as the mode-line.  I haven't tested it much but it appears to work.
>
> As you suggested it doesn't use a function such as
> `header-button-format'.  Instead `make-text-button' was changed to
> return a useful value when BEG is a string: the propertized string.
>
> ,----
> | (setq header-line-format
> |       (make-text-button "test" nil
> |                         'action (lambda (button)
> |                                   (message "Button: %s" button))))
> `----
>
> The above is enough now to insert a button in the header-line or
> mode-line.  No need for an intermediate variable to hold the string.
> Additionally the following changes are needed so that clicking the
> button actually does something.
>
> Add an additional kind of "button object" that is used internally and
> passed to the button action function: "area buttons" (analogously to
> `posn-area').  Normally these have the form (STRING . STRING-POS), where
> STRING is the propertized string and STRING-POS is list of the form
> returned by `event-start'.  STRING-POS might be useful in actions but
> isn't used internally.  Area button objects can also be just a string.
>
> [mode-line mouse-2] and [header-line mouse-2] are bound to push-button
> just like [mouse-2].  [follow-link] is not actually used at all.  (I
> think it was used instead of [mouse-2] in the past, but I might be
> wrong).
>
> I don't know whether binding these events might cause problems for
> regular buttons, but it does not appear to be the case.
>
> (Maybe using follow-link instead and extending it to work in the
> header-line and mode-line would be better; but I know to little about
> that.  The little I do know tells me doing so would probably not be
> worth the effort.)
>
> `push-button', `button-get', `button-put', `button-label' are taught to
> deal with area buttons.  Using `button-start', `button-end' and
> `button-at' with an area button causes an error.  Of the "button
> creating functions" only `make-text-button' is useful for area buttons.
> `[next|previous|forward|backward]-button' also cannot be used.
>
> The patch is against 24.3.50 from a few days ago but if necessary I can
> redo it against a different version.
>
>