Subject: Re: bug#70086: Mouse clicks in tab-bar don't call commands bound in keymap properties

From: Juri Linkov <[email-masked]>
Date: Sat, 30 Mar 2024 20:16:50 +0200

> In my listen.el package on GNU ELPA, I'm trying to make mouse clicks in the
> `global-mode-string' construct work when `mode-line-misc-info' is shown in
> the tab-bar by including `tab-bar-format-global' in `tab-bar-format'.  I'm
> including this construct in the `global-mode-string':
>
>
>   `(listen-mode (:propertize listen-mode-lighter
>                              keymap ,listen-mode-lighter-map))

Thanks for the request.  If possible could you send a minimal test case
to see what exactly do you need.

> When that construct is used in `mode-line-format', it works as expected:
> clicking with mouse-1 calls the command `listen-pause'.

And the same should work on `tab-line-format' as well.

> Looking at tab-bar.el, I see that it does some, I suppose, unusual things
> with keymaps and clicks to make them work.  However, if this could be fixed
> to allow these commands to work properly, it would be very useful, as the
> extra space in the tab-bar is a great place to display extra information
> without crowding the mode line.

Indeed, events on the tab-bar have a different design where
`tab-bar--event-to-item' should be used to get a bound command.
You can see an example in `tab-bar-mouse-down-1' that uses
(if (functionp (nth 1 item)) (call-interactively (nth 1 item))
to call an arbitrary command.