Professional Web Applications Themes

modaldialog with carbon events? - Mac Programming

I'm trying to do a tiny basic modal dialog to get a single numerical value from an edit text field. The modal dialog properly detects button clicks and detects focus changes on the text field (so when I click on the text it detects it). However, any text I type doesn't appear or otherwise overwrite the text field. I have determined that all the ordinary event handlers I have installed are still working while the modal dialog is running. It's strange because I can manipulate a window behind the modal dialog even though I obviously can't bring it to the ...

  1. #1

    Default modaldialog with carbon events?

    I'm trying to do a tiny basic modal dialog to get a single numerical value
    from an edit text field. The modal dialog properly detects button clicks
    and detects focus changes on the text field (so when I click on the text
    it detects it). However, any text I type doesn't appear or otherwise
    overwrite the text field. I have determined that all the ordinary event
    handlers I have installed are still working while the modal dialog is
    running. It's strange because I can manipulate a window behind the modal
    dialog even though I obviously can't bring it to the front. I suspect
    that keystrokes are getting shunted to some key down event handler instead
    of going to the modal dialog. It is true that I am using my own keyboard
    handler for key down, key repeat, and key up events, which is necessary
    for other parts of the program.

    Does anyone know what's going on here and what I can do about it? Here is
    my modal dialog code that doesn't seem to work (which would have certainly
    worked fine in old nonCarbon apps and even in some Carbon apps I've
    written that use WaitNextEvent instead of Carbon event handlers, I've
    been using modal dialogs for years without any problem):

    ------------------------------------------------------

    DialogPtr dialog;
    Boolean dialogDone = false;
    short itemHit, itemType;
    Handle itemHandle;
    Rect itemRect;

    dialog = GetNewDialog(128, nil, (WindowPtr) -1L);

    ShowWindow((WindowPtr)dialog);
    SetPort(GetDialogPort(dialog));

    SetDialogDefaultItem(dialog, 1);

    GetDialogItem(dialog, 3, &itemType, &itemHandle, &itemRect);
    SetDialogItemText(itemHandle, "\p0");

    while (!dialogDone)
    {
    ModalDialog(nil, &itemHit);

    switch (itemHit)
    {
    case 1:
    case 2:
    dialogDone = true;
    break;
    case 3:
    //Not really anything to do here, so I beep, just
    to
    //prove that I am successfully catching mouse
    clicks
    //in the text edit field
    SysBeep(1);
    break;
    }
    }

    Str255 textValue;
    GetDialogItem(dialog, 3, &itemType, &itemHandle, &itemRect);
    GetDialogItemText(itemHandle, textValue);

    long valueEntered;
    StringToNum(textValue, &valueEntered);

    DisposeDialog(dialog);

    if (itemHit == 2)
    return;

    //Go ahead and use the "valueEntered" variable as I see fit

    __________________________________________________ ______________________
    Keith Wiley unm.edu
    http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Guest

  2. #2

    Default Re: modaldialog with carbon events?

    On Wed, 3 Dec 2003, Keith Wiley wrote:
     

    In your key handlers, are you sure that you are returning
    eventNotHandledErr when appropriate?

    Fred
     

    Frederick Guest

  3. #3

    Default Re: modaldialog with carbon events?

    In article <cs.unm.edu>,
    Keith Wiley <unm.edu> wrote: 

    Casting between dialogs/windows/ports is illegal in Carbon. This line
    should be:
    ShowWindow(GetDialogwindow(dialog))
    Tom Guest

  4. #4

    Default Re: modaldialog with carbon events?

    On Thu, 4 Dec 2003, Frederick Cheung wrote:
     

    That did it. Thanks.

    __________________________________________________ ______________________
    Keith Wiley unm.edu
    http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Guest

  5. #5

    Default Re: modaldialog with carbon events?

    ModalDialog is not "Carbon Events". It is Classic events. In Carbon you
    use RunAppModalLoopForWindow and use Carbon events for hit, click and
    such.

    --
    Norman Black
    Stony Brook Software

    "Keith Wiley" <unm.edu> wrote in message
    news:cs.unm.edu... 
    value 
    clicks 
    text 
    event 
    modal 
    instead 
    keyboard 
    necessary 
    Here is 
    certainly 
    __________________________________________________ ______________________ 
    http://www.mp3.com/KeithWiley 
    Flatland 
    __________________________________________________ ______________________

    Norman Guest

Similar Threads

  1. Replies: 19
    Last Post: December 3rd, 10:32 AM
  2. OSX Carbon Console???
    By Dr. Michael M. Cohen in forum Mac Programming
    Replies: 3
    Last Post: September 16th, 02:32 AM
  3. KeyFilters (Carbon)
    By Andrew Clay in forum Mac Programming
    Replies: 0
    Last Post: September 12th, 06:23 AM
  4. Using Image Well with Carbon API
    By Frederick Cheung in forum Mac Programming
    Replies: 0
    Last Post: August 10th, 10:00 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