Solved

trackcontrol problem with pop-up menu

Posted on 1998-09-05
1
217 Views
Last Modified: 2013-12-26
I thought that TrackControl took care of displaying the associated menu when a mousedown event occured in the control.

popDownHdl = GetNewControl( 130, myWindow); // System 7 pop-up

      switch (FindWindow(myEvent.where,&hitWindow))      {
                                    case inContent:
                                    
                                          GlobalToLocal(&myEvent.where);
                                          hitControl=FindControl(myEvent.where,myWindow,&hitControlHdl);
                                        if(hitControlHdl == popDownHdl)
                                          {      Handle selection
        }
0
Comment
Question by:dwp090598
1 Comment
 
LVL 3

Accepted Solution

by:
boonstra earned 50 total points
ID: 1291521
TrackControl does take care of displaying the menu when a mouseDown occurs.  The code snippet below works properly.  Things to check: (1) is your popDownHandle nil, (2) does your popup control have the correct procID (1008), (3) is the menu properly associated with the control ((**popDownHandle).contrlMin == menuID, or (4) are you sending the correct actionProc value to TrackControl (should be -1),

Working snippet:

ControlHandle popDownHandle;
.
      popDownHandle = GetNewControl(130, gWindow);
      if (popDownHandle==nil) DebugStr("\p nil control handle");
.

static void DoPopupMenu(Point pt,ControlHandle ctl)
{
      short part,menuItem;
      part = TrackControl(ctl,pt,(ControlActionUPP)-1);
      menuItem = GetControlValue(ctl);
      /* process menu selection */
}

static int DoMouse(EventRecord *ev)
{
      WindowPtr wind;
      short part;
      int res = 0;

      part = FindWindow(ev->where, &wind);
            
      switch (part) {
            case inContent:
            {
                  ControlHandle theControl;
                  int part;
                  Point pt;
                  pt = ev->where;
                  GlobalToLocal(&pt);
                  part = FindControl(pt, wind, &theControl);
                  if (theControl==popDownHandle) {
                        DoPopupMenu(pt,theControl);
                  }
                  break;
            }
                  
      }
      
      return res;
}

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now