Solved

trackcontrol problem with pop-up menu

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WordPress: Need a simple quiz plug-in 2 117
Parse keys to return portion of key with Regex 3 92
fizzArray  challenge 1 57
How do I promote a cleaning service best? 16 61
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
A great marketing strategy is diverse.  Read about the not so popular, yet effective, marketing tactics you can start using today!
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
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.

932 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

11 Experts available now in Live!

Get 1:1 Help Now