From: jxt@stc06.ctd.ornl.gov (TOLLIVER J S)
Subject: Re: How to make mouse button 2 act like mouse button 1
Reply-To: jxt@stc06.ctd.ornl.gov (TOLLIVER J S)
Organization: Oak Ridge National Laboratory
Date: Wed, 30 Sep 1992 12:42:46 GMT

Since the reply to which I am following up was posted on comp.windows.x,
I'll post here too. For readers who may have missed the original post, it
was in comp.windows.x.motif only.

In article <1992Sep29.191926.9364@ERA.COM>, feit@ERA.COM (Mark Feit) writes:
>On comp.windows.x.motif, jxt@stc06.ctd.ornl.gov (TOLLIVER J S) posts:
> > 
> > Hi. I have a need to make mouse button 2 act identically to mouse button 1
> > in a Motif application.
> >
> > [Translation stuff discussed below]
> >
> > I have several questions:
> > 
> > 1. Most importantly, how can I make MB2 function EXACTLY like MB1,
> > to the user?
> > 4. How can this be fixed so that it works universally?
>
>Universally? With translations?  Can't be done.  The trick here is not
>to modify any of your clients, because inevitably you're going find a
>few that you won't have source for or will be running from another
>host.  Once you start trying to tweak your clients, you've pretty much
>demolished some of the things that make X stand out from other
>environments.  So leave the clients alone and concentrate on how to
>make the environment do what you want.
>
First, thanks for the thoughtful reply. But perhaps I should elaborate on
my needs a bit more:

Actually, in this case, it is a custom, in-house application for which the
customer has requested that MB2 act like MB1. The reason is that my app
communicates with a 3rd-party CAD app where MB2 is used to select entities on
the screen. It's confusing to have to use MB1 in my app and MB2 in the other
app. The other app, of course, I have no control over. But mine, I certainly
have the source to and the will to modify the source as needed to meet
customer needs. By "universal" I don't mean "all the time for all clients on
all possible host/server combinations." I do mean "all the time for my ONE
client on all possible host/server combinations." For right now, all
possible host/server combinations means HP and SG and may grow to include
X terminals. That's all.

>I can think of three solutions, two software and one hardware:
>
>The best bet is to tweak your server so that anything that comes from
>button 2 gets reported as button 1. 

Without server source, this isn't possible. Or even desirable, given the
new definition of "universal" above. I only want this behavior for this app,
not all clients that I ever run.
>
>Second best (and certainly acceptable, although possibly more
>cumbersome) is a filter program that sits between the server and
>clients and translates events so anything reported on Button 2 gets
>changed to Button 1.

Interesting idea, but, again, not desirable for my needs. Perhaps "universal"
was a poor choice of words...

>Cons: Slight
>tradeoff in speed and knowledge of how to program with sockets and how
>the X protocol works is also required (If you're not up to it the
>server mod will be less painful).  The XTV program on the R5 contrib
>tape is such a filter, albeit a complex one.  If there's sufficient
>interest in how something like this is done, we could start a thread
>about it on comp.windows.x and explore it piece by piece.
>
This would be interesting, but only of academic interest to me at this point.
Thanks for the offer, but I'll let others express an academic interest before
suggesting that such a thread be started.

>Third (and worst, IMHO) is a customized mouse with Button 2 hardwired
>to Button 1.  I won't go into that one, 'cause a software solution is
>always a better deal if you can swing it.  Pros: Requires no software
>mods, a plus if the other two solutions aren't possible for some
>reason.  Cons: Requires customization of hardware.  Not cheap.
>
I agree...worst solution. But would certainly work given your interpretation
of my use of the word "universal."

> > The closest I've come so far is this translation,
> > which I don't even fully understand:
> > 
> > *XmPushButton.translations: #augment\
> > 			       <Btn2Down>: Arm()\n\
> > 			       <Btn2Up>: Activate() Disarm()\n\
> > 			       <EnterWindow>: Enter()\n\
> > 			       <LeaveWindow>: Disarm(NoRedisplay) Leave()
> > 
> > 2. What's wrong with the above resource specification?
>
>Well, for starters it only works with Motif PushButtons.  That's all
>good and fine if all the world's a Motif PushButton, but there are
>other widgets in the world that won't honor the translation.
>
Good point. I would settle for PushButtons, ToggleButtons, and Texts. Also,
option menus, which mainly consist of PushButtons so they would probably
work, but the menu must drop down with MB2 on the option menu button gadget
too. Possible?

> > 5. Arm, Activate, and Disarm are PushButton action routines? Where are
> > the Enter and Leave action routines? Where are they documented?
>
>XmPushButtons don't have Enter() and Leave() actions; these are simply
>"additional behaviors" defined by the widget.  There probably should
>be Enter() and Leave() actions, but there's probably some reason there
>aren't.  (Anybody know why?)
>
Ah! I found this "additional behavior" somewhat documented in the OSF/Motif
Programmer's Reference by OSF. (It gets only one sentence in O'Reilly Vol. 6,
which I normally use as my reference.) But even in the OSF book, the Enter()
and Leave() functions are not documented, just the <EnterWindow> and
<LeaveWindow> events. Where are Enter() and Leave() documented? Also, where
is the NoRedisplay argument to Disarm() documented?

> > 3. Why the difference on HP vs SG?
>
>Dunno.  Any takers?
>
> > 7. And better yet, exactly what does the universally correct resource
> > do?                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>There is no such animal.  Most programs written with Xlib don't even
>_use_ resources, and those which use Xt won't all recognize the same
>translation.
>
Again, by "universal" I mean just one client and just a few Motif widgets
in that client -- no pure Xlib stuff here. But I do want it to work for
multiple possible host/server combinations. I don't mind changing the source
since this is a customer-driven request, but I would rather do it with a
translation table resource, if possible.

Thanks again,
Johnny Tolliver
Oak Ridge National Laboratory
jxt@ornl.gov