Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!sgi!shinobu!fido.wpd.sgi.com!marktwain.rad.sgi.com!linton From: linton@marktwain.rad.sgi.com (Mark Linton) Newsgroups: comp.windows.interviews Subject: Re: "odd" Button state Message-ID: <1991May14.223406.20281@fido.wpd.sgi.com> Date: 14 May 91 22:34:06 GMT References: <"<9105132259.AA23725@cnmus.cnm.us.es> Sender: news@fido.wpd.sgi.com (Usenet News Admin) Reply-To: linton@marktwain.rad.sgi.com (Mark Linton) Organization: sgi Lines: 140 In article <"<9105132259.AA23725@cnmus.cnm.us.es>, juando@cnm.us.es writes: |> |> Playing with alert, I found that if you press and hold any mouse button |> outside the screen button and then move the pointer inside it and release, the |> button enters an "odd" state: Although no mouse button is pressed, it is |> highlighted whenever the pointer enters it. Looking at the code that implements |> Button class you can see that it is "swallowing" mouse events. I could fix |> that with the patch that follows, but I'm not sure if that is the desired |> behavior for Button. Can you tell me if this is right? Your changes looked ok, but Button really should use grab by deriving from PointerHandler instead of having its own read loop. Below are new versions of button.h and button.c that seem to work. /* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Button - clickable Action */ #ifndef ivlook_button_h #define ivlook_button_h #include #include class Action; class Listener; class Telltale; class Button : public MonoGlyph, public PointerHandler { public: Button(Action*, Telltale*); virtual void drag(Event&); virtual void release(Event&); virtual void commit(Event&); protected: virtual ~Button(); private: Action* action_; Listener* listener_; Telltale* telltale_; }; #endif /* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Button - clickable Action */ #include #include #include #include #include #include #include Button::Button(Action* a, Telltale* t) : MonoGlyph(nil), PointerHandler() { action_ = a; Resource::ref(action_); telltale_ = t; Resource::ref(telltale_); listener_ = new Listener(telltale_, this); listener_->sensor()->button(true, Event::any); listener_->sensor()->motion(true); body(listener_); } Button::~Button() { Resource::unref(action_); action_ = nil; Resource::unref(telltale_); telltale_ = nil; } void Button::drag(Event& e) { if (telltale_ != nil) { telltale_->highlight(listener_->picks(e.pointer_x(), e.pointer_y())); } } void Button::release(Event& e) { if (telltale_ != nil) { telltale_->highlight(false); } PointerHandler::release(e); } void Button::commit(Event& e) { if (action_ != nil && listener_->picks(e.pointer_x(), e.pointer_y())) { action_->execute(); } }