mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (04/08/90)
> I need to be able to cause two different actions depending on whether > I click once or twice on a mouse button. My translation table looks > (in part) like this: > <Btn1Down>(2): action_one\n\ > <Btn1Down>,<Btn1Up>: action_two\n\ > With this table, a single click calls action_two as required, but a > double click calls action_two followed by action_one. How can I > ensure action_two is not called from a double click? I think you can't. You see, X does not have mouse clicks. All it has is button presses and releases. (And motion events, but those are irrelevant to the discussion at hand.) Xt tries to fake clicks with this, but the lack of a mouse timeout event makes it difficult, and the result therefore has problems, not surprisingly. In particular, if you want to do <foo> on a single click and <bar> on a double click, you have to make sure either that <foo> is a subset of <bar> or that <foo> is undoable. This is because <foo> is done after the first click regardless of whether it's the first click of a double-click or not. I think X should have mouse timeout events of some sort, that is, some sort of event that can be requested saying that "the mouse hasn't changed state in <time>", where <time> is settable somehow, either globally, per-client, per-window, or per-<client,window>-pair. (Ideally all four, of course.) This would allow multiple clicks to be done reliably. (Clicks could also be made into events in their own right, but "mechanism not policy"; someone may want pointer-idle events for something else.) Perhaps if nobody else does I'll put together an extension and see how it goes. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu
converse@EXPO.LCS.MIT.EDU (Donna Converse) (04/09/90)
> I need > to be able to cause two different actions depending on whether I click once > or twice on a mouse button. My translation table looks (in part) like this: > > <Btn1Down>(2): action_one\n\ > <Btn1Down>,<Btn1Up>: action_two\n\ > > With this table, a single click calls action_two as required, but a double > click calls action_two followed by action_one. <Btn1Down>(2) is equivalent to specifying <Btn1Down>,<Btn1Up>,<Btn1Down>. The event sequence of one of your translations is an initial subsequence of the other. When the longer event sequence occurs, the Intrinsics will take the actions specified for both event sequences, as you have observed. > How can I ensure action_two is not called from a double click? Rework the action corresponding to a single click to be a timer callback procedure. Add the timer callback in a new action procedure which is bound to <Btn1Down>,<Btn1Up>; remove the timer callback and do the double click stuff if the action procedure is called again in some small amount of time. > The order of the two entries in the table doesn't seem to matter, and some > alternatives I have tried (for instance, omitting the <Btn1Down> on the > second line) do not call action_two at all. Right, and try pressing the button down outside of your application and releasing it over your application to see the effect of the latter. > If X windows insists on calling action_two in all cases, must I wait a bit > and see if there is another <Btn1Down> event waiting? Yes, in one way or another, the single click action must be deferred. Donna Converse converse@expo.lcs.mit.edu
doyle@ingr.com (Doyle Davidson) (04/10/90)
In article <9004080623.AA02917@Larry.McRCIM.McGill.EDU>, mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) writes: > > I think X should have mouse timeout events of some sort, that is, some > sort of event that can be requested saying that "the mouse hasn't > changed state in <time>", > Perhaps if nobody else does I'll put together an extension and see how > it goes. > > der Mouse Don't bother, I have already done it. It is a little complicated because you have to handle pointer grabs correctly but it is doable. Probably about 100 lines of hacking in "event.c" plus the extension registration stuff, Xlib bindings, and the signalling mechanism in the server. It makes multiple clicks easy to recognize without a timer. But I don't know if it can be wedged into Xt easily. We use it proprietarily. (Is that a word? English always was my worstest subject) There are other issues like what happens when you: in window 1: <Down> <Up> then move to window 2 quickly and click again Each window gets it's own up/down combo but where do you send the timeout to? Both? just the last? What I did was force a pseudo timeout on the leave. I would prefer to find a way to do it as an X input extension in R4 so that "events.c" is left untouched from MIT, but it is so intimately tied to the mouse. Doyle ------------------------------- Doyle C. Davidson Intergraph Corp. Workstation Graphics Standards 1 Madison Industrial Park Huntsville, AL 35806 (205) 730-2000 ..!uunet!ingr!b11!doyled!doyle or doyle@ingr.com -------------------------------