Solved

trackcontrol problem with pop-up menu

Posted on 1998-09-05
1
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Read about why website design really matters in today's demanding market.
For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
An overview of how to create reports in Adobe Analytics (formerly Omniture Site Catalyst) using pageNames, events, eVars and props. This video will show you how to install the Omniture Debugger tool so can see (and test) what is being passed int…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

752 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