Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is the status of Tk regarding extra mouse buttons?

36 views
Skip to first unread message

Georgios Petasis

unread,
Nov 27, 2011, 5:42:22 AM11/27/11
to
Hi all,

I want to use the extra buttons my mouse has (the ones on the side, that
map to next/prev in browser) in Tk.

Is this possible?

George

Georgios Petasis

unread,
Nov 27, 2011, 6:07:59 AM11/27/11
to
I see than under windows, these two buttons are called XBUTTON1,
XBUTTON2, and new events have been defined:

WM_XBUTTONDBLCLK
WM_XBUTTONDOWN
WM_XBUTTONUP

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646245%28v=VS.85%29.aspx

Also Qt names them XButton:
http://doc.qt.nokia.com/4.7/qt.html#MouseButton-enum

But looking at win/tkWinX.c, I see no reference about any of these.

I suppose this means no, or there is hope if I register some event
callback of my own?

George

Andreas Leitgeb

unread,
Nov 27, 2011, 2:58:21 PM11/27/11
to
Georgios Petasis <pet...@iit.demokritos.gr> wrote:
> Στις 27/11/2011 12:42, ο Georgios Petasis έγραψε:
>> Hi all,
>> I want to use the extra buttons my mouse has (the ones on the side, that
>> map to next/prev in browser) in Tk.

I don't know how "platform-neutral" that will be, but you can try this:

wish
% bind . <Button> {puts %b}

Then click various buttons (or scroll wheels) on the main window.

Here on linux, I get 4 and 5 for scrolling up and down,
and I get 8 and 9 for two buttons at the left side of my mouse.
If I plug in an apple-mightymouse, with scroll-ball, then
scrolling sideways gives me 6 and 7, btw.

You can however NOT use these higher numbers for naming events
like <Button-8> - that only works up to 5. I guess you could
bind to <ButtonPress>, and then check the %b field to see, which
button it was.

Georgios Petasis

unread,
Nov 28, 2011, 4:04:58 AM11/28/11
to
Interesting that it works under Linux, although they are not mapped to
standard mouse events (as there are no definitions in Xlib I suppose).
I come across this mail:
http://www.mail-archive.com/kde-cor...@kde.org/msg01483.html
that seems to try and "summarise" the status under Linux.

Under windows though, the above does not work, as new window messages
have been defined for these "XButtons", so they are not handled by Tk
(although it is easy to add such support).

George

Andreas Leitgeb

unread,
Nov 28, 2011, 8:09:02 AM11/28/11
to
Georgios Petasis <pet...@iit.demokritos.gr> wrote:
> Στις 27/11/2011 21:58, ο/η Andreas Leitgeb έγραψε:
>> Georgios Petasis<pet...@iit.demokritos.gr> wrote:
>>> Στις 27/11/2011 12:42, ο Georgios Petasis έγραψε:
>>>> Hi all,
>>>> I want to use the extra buttons my mouse has (the ones on the side, that
>>>> map to next/prev in browser) in Tk.
>> I don't know how "platform-neutral" that will be, but you can try this:

> Under windows though, the above does not work, as new window messages
> have been defined for these "XButtons", so they are not handled by Tk
> (although it is easy to add such support).

How about a TIP ?

Georgios Petasis

unread,
Nov 28, 2011, 5:22:11 PM11/28/11
to
Στις 28/11/2011 15:09, ο/η Andreas Leitgeb έγραψε:
> Georgios Petasis<pet...@iit.demokritos.gr> wrote:
>> Στις 27/11/2011 21:58, ο/η Andreas Leitgeb έγραψε:
>>> Georgios Petasis<pet...@iit.demokritos.gr> wrote:
>>>> Στις 27/11/2011 12:42, ο Georgios Petasis έγραψε:
>>>>> Hi all,
>>>>> I want to use the extra buttons my mouse has (the ones on the side, that
>>>>> map to next/prev in browser) in Tk.
>>> I don't know how "platform-neutral" that will be, but you can try this:
>
>> Under windows though, the above does not work, as new window messages
>> have been defined for these "XButtons", so they are not handled by Tk
>> (although it is easy to add such support).
>
> How about a TIP ?
>

Unfortunately, I think one is needed :D

George

Donal K. Fellows

unread,
Nov 29, 2011, 10:56:18 AM11/29/11
to
On 28/11/2011 09:04, Georgios Petasis wrote:
> Interesting that it works under Linux, although they are not mapped to
> standard mouse events (as there are no definitions in Xlib I suppose).

They should map to ButtonPress and ButtonRelease events just fine, as
the field for the button number can hold quite enough values for any
even remotely sane mouse. The problem is that there's no standard event
mask for handling dragging with high-numbered buttons; that's much more
messy...

Donal.

Georgios Petasis

unread,
Nov 29, 2011, 1:21:09 PM11/29/11
to
Dear Donal,

Well, I think the detail passes (the integer in button event), but
since X does not define the masks for buttons above 5, the Tk modifiers
(Button1-5, B1-5, etc) do not work. I am not sure if <6> works (I don't
have a real system to test the mouse - only VMs).

We need to somehow support these, which requires a TIP, as Andreas
suggested... :-)

Regards,

George
0 new messages