Fix for odd button behavior

From: Glen R. Salo (salo@coax.net)
Date: Thu May 06 1999 - 05:17:12 MEST


Dear Rooters,

I've noticed an odd behavior in TGTextButtons, TGRadioButtons, and
TGCheckButtons.  Run test/guitest, click on select Dialog... from the Test pull
down menu and click on Tab 2.  Then press mouse button 1 over Button 1.  Now,
without releasing the mouse button, move the cursor over Button 2, Check 1,
Check 2, etc. The Text buttons will depress when you move the mouse over them,
the Check buttons will become checked, and the radio buttons will be selected. 
In fact, it is possible to get all of the radio buttons selected at one time! 
My fix for this behavior is given below.  I hope this helps someone.

Glen

*********************************************************************

Glen R. Salo                                   g.r.salo@ieee.org
Mission Research Corporation                   (937)429-9261 Ext. 119
3975 Research Boulevard                        (937)429-2625 Fax
Dayton, Ohio 45430-2108

*********************************************************************


Bool_t TGButton::HandleCrossing(Event_t *event)
{
   // Handle mouse crossing event.

   if (fTip) {
      if (event->fType == kEnterNotify)
         fTip->Reset();
      else
         fTip->Hide();
   }

   if (!event->fCode) return kTRUE;  // My fix

   if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
      return kTRUE;

   if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;

   if (event->fType == kEnterNotify)
      SetState(kButtonDown);
   else
      SetState(kButtonUp);

   return kTRUE;
}

Bool_t TGCheckButton::HandleCrossing(Event_t *event)
{
   // Handle mouse crossing event.

   if (fTip) {
      if (event->fType == kEnterNotify)
         fTip->Reset();
      else
         fTip->Hide();

   }

   if (!event->fCode) return kTRUE;  // My fix

   if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
      return kTRUE;

   if (fState == kButtonDisabled) return kTRUE;

   if (event->fType == kEnterNotify) {
      PSetState((fPrevState == kButtonUp) ? kButtonDown : kButtonUp);
   } else {
      PSetState(fPrevState);
   }
   return kTRUE;
}

Bool_t TGRadioButton::HandleCrossing(Event_t *event)
{
   // Handle mouse crossing event.

   if (fTip) {
      if (event->fType == kEnterNotify)
         fTip->Reset();
      else
         fTip->Hide();

   }

   if (!event->fCode) return kTRUE;  // My fix

   if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
      return kTRUE;

   if (fState == kButtonDisabled) return kTRUE;

   if (event->fType == kEnterNotify) {
      PSetState(kButtonDown);
   } else {
      PSetState(fPrevState);
   }
   return kTRUE;
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:32 MET