Solved

trackcontrol problem with pop-up menu

Posted on 1998-09-05
1
251 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Learn about the eCommerce marketing trends for the year ahead.
There is a massive demand for content on the web right now, and it doesn't look like it's going to stop any time soon. But, if you are running a business blog, it's not just enough to offer your audience lots of content. It needs to be high-quality…
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…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

617 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