Professional Web Applications Themes

question: detection of double clicking - Mac Programming

Hi, I am trying to make a function to detect mouse double clicking in a C program. I can see whether the mouse is down or not, but I do not know how to record the time when the mouse was being pressed. Can anyone tell me how to peek the timer for this purpose or a better way of catching the double clicking? B-G,...

  1. #1

    Default question: detection of double clicking

    Hi,
    I am trying to make a function to detect mouse double clicking in a C
    program. I can see whether the mouse is down or not, but I do not know how
    to record the time when the mouse was being pressed. Can anyone tell me how
    to peek the timer for this purpose or a better way of catching the double
    clicking?

    B-G,


    B.G. Guest

  2. #2

    Default Re: question: detection of double clicking

    In article <bodq87$8g2$accu.uu.nl>,
    "B.G. Khang" <uu.nl> wrote: 

    I'm going to assume you have an event (either Classic style or Carbon
    style) available. Check the event time -- for a Classic style that's
    myEvent->when, for Carbon call GetEventTime().

    If you are using Carbon events, however, it is easier to simply look at
    kEventParamClickCount within the event, which will tell you for a given
    mouse down if this is the 1st, 2nd, 3rd, etc mouse click in a "double
    click" sequence.

    If for some bizarre reason you don't have events available at this point
    in your code, call TickCount() to find out the time when you are
    processing the mouse down and call GetDblTime() to find out how close
    together the system wants events to be in order to consider them double
    clicks. This approach, however, isn't as accurate because there can be
    a delay between when an event is posted and when you get around to
    actually processing it.
    Tom Guest

  3. #3

    Default Re: question: detection of double clicking

    Thank you very much for your answer.

    I am not using Carbon stuff, but a classic, Mac OS. THe following is the
    function for checking mouse down and key pressing, which was drafted from
    the sample program of Opengl full screen mode in the Apple site. Would you
    mind looking over these codes and telling me where I can put the TickCount()
    function.

    Thanks in advance.

    void DoEvent (void)
    {
    EventRecord theEvent;
    WindowRef whichWindow;
    SInt16 whatPart;
    Boolean fProcessed;

    // profile
    #if __profile__
    if (noErr == gProfErr)
    ProfilerSetStatus(TRUE); // turn on profiling
    #endif

    if (WaitNextEventWrapper(everyEvent, &theEvent, gSleepTime, NULL))
    {
    DSpProcessEventWrapper (&theEvent, &fProcessed);
    if (!fProcessed)
    {
    switch (theEvent.what)
    {
    case mouseDown: pos0 = LMGetMouseTemp( );MouseDown=true;

    whatPart = FindWindow (theEvent.where, &whichWindow);
    switch (whatPart)
    {
    case inContent:
    if (gpWindow != FrontWindow())
    SelectWindow (gpWindow);
    break;
    case inMenuBar:
    {
    SInt32 menuResult = MenuSelect (theEvent.where);
    if (HiWord (menuResult) != 0)
    DoMenu (menuResult);
    }
    break;
    case inDrag:
    {
    // full screen no drag
    }
    break;
    case inGrow:
    {
    // full screen no grow
    }
    break;
    case inGoAway:
    {
    // full screen no go away
    }
    break;
    case inZoomIn:
    case inZoomOut:
    {
    // full screen no zoom
    }
    break;
    case inSysWindow:
    #if !TARGET_API_MAC_CARBON
    SystemClick(&theEvent, whichWindow);
    #endif // !TARGET_API_MAC_CARBON
    break;
    }
    break;
    case keyDown:
    case autoKey:
    {
    SInt8 theKey;
    SInt8 theCode;
    theKey = theEvent.message & charCodeMask;
    theCode = (theEvent.message & keyCodeMask) >> 8;
    if ((theEvent.modifiers & cmdKey) != 0)
    {
    SInt32 menuResult = MenuKey (theKey);
    if (HiWord(menuResult) != 0)
    DoMenu (menuResult);
    }
    else {

    DoKey (theKey, theCode);
    }
    }
    break;
    #if TARGET_API_MAC_CARBON
    case activateEvt:
    if (theEvent.modifiers & activeFlag)
    InstallEventLoopTimer (GetCurrentEventLoop(), 0, 0.000001, GetTimerUPP
    (), 0, &gTimer);
    else
    {
    RemoveEventLoopTimer(gTimer);
    gTimer = NULL;
    }
    break;
    #endif // TARGET_API_MAC_CARBON
    case updateEvt:
    {
    UpdateWrapper (&theEvent);
    }
    break;
    case diskEvt:
    break;
    case osEvt:
    if (theEvent.message & 0x01000000) // Suspend/resume event
    {
    if (theEvent.message & 0x00000001) // Resume
    {
    gSleepTime = kForegroundSleep;
    gfFrontProcess = true;
    }
    else
    {
    gSleepTime = kBackgroundSleep; // Suspend
    gfFrontProcess = false;
    }
    }
    break;

    case kHighLevelEvent:
    AEProcessAppleEvent (&theEvent);
    break;
    }
    }
    }
    #if !TARGET_API_MAC_CARBON
    else
    DoUpdate (gpWindow);
    #endif // !TARGET_API_MAC_CARBON
    // profile
    #if __profile__
    if (noErr == gProfErr)
    ProfilerSetStatus(FALSE); // turn profiling off again
    #endif
    }


    B.G. Guest

  4. #4

    Default Re: question: detection of double clicking

    In article <boe1cj$lk2$accu.uu.nl>,
    "B.G. Khang" <uu.nl> wrote: 

    No, I'm afraid I'm not going to write your code for you. However, since
    you have events, you can check theEvent.when to find out when the mouse
    down happened.
    Tom Guest

Similar Threads

  1. Double Clicking on a PDF doent, will not open
    By matt_spree@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 5
    Last Post: October 11th, 03:25 PM
  2. Double-clicking opens ID but not file
    By Bob_Bob@adobeforums.com in forum Adobe Indesign Windows
    Replies: 3
    Last Post: June 16th, 03:42 AM
  3. Double Clicking Problems
    By zoranb@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 2
    Last Post: May 6th, 08:31 PM
  4. Double Clicking doesn't open files
    By Chris_Koch@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 1
    Last Post: April 1st, 02:31 PM
  5. Double-clicking
    By GallyG webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 6th, 09:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139