Professional Web Applications Themes

Help with Popup Menus in Windows (OS 9 Appearance) - Mac Programming

In article <oster-BA9147.20104705072003newssvr19-ext.news.prodigy.com>, David Phillip Oster <osterieee.org> wrote: >If you are using popupmenuControls, >In your mouseDown handler, you should be calling: > >FindControl(), and if it is a control, then TrackControl(). If >TrackControl() returns non-zero, do a GetControlValue() to see which >item the user selected. Thanks, I see the mistake I was making now. Shouldn't I be using FindControlUnderMouse() and HandleControlClick() now? It seems that whatever pair I use that I get another problem: I have a window with a popup menu that can open any of five dialogs, all that is working, BUT if I open one, select the ...

  1. #1

    Default Re: Help with Popup Menus in Windows (OS 9 Appearance)

    In article <oster-BA9147.20104705072003newssvr19-ext.news.prodigy.com>,
    David Phillip Oster <osterieee.org> wrote:
    >If you are using popupmenuControls,
    >In your mouseDown handler, you should be calling:
    >
    >FindControl(), and if it is a control, then TrackControl(). If
    >TrackControl() returns non-zero, do a GetControlValue() to see which
    >item the user selected.
    Thanks, I see the mistake I was making now.
    Shouldn't I be using FindControlUnderMouse() and HandleControlClick() now?

    It seems that whatever pair I use that I get another problem:

    I have a window with a popup menu that can open any of five dialogs, all
    that is working, BUT if I open one, select the window and open another and
    then close it the popup no longer works correctly.

    My window comes to the front and is activated as it should be, but clicking
    on the popup does not open the menu! FindControl is returning zero in this
    condition. If I click on the first dialog and then on the window again the
    popup works again.
    This does not happen with one dialog & window, only if I open more than one
    and close the last leaving the window in front.
    All the dialogs are modeless and closed with HideWindow(). I know my window
    is in front and I get the mouseDown inContent click and I call FindControl
    explicitly with that window's pointer, but it returns zero for the part and
    the control handle, like this:

    if ( wp == Keeper )
    {
    Point position;
    ControlHandle control;
    ControlPartCode code;
    SInt16 part;

    position = event->where;
    GlobalToLocal( &position );

    part = FindControl( position, Keeper, &control );
    // control = FindControlUnderMouse( position, Keeper, &part );
    if ( control == _keeper_popup )
    {
    if ( TrackControl( control, position, NIL) )
    // code = HandleControlClick( control, position, event->modifiers, NIL );
    // if ( code != kControlNoPart )
    Do_Popup_Check( );
    }
    }

    I think I'm getting an incorrect mouse position, even if I close with Cmd-W
    ie without a click, the coordinates are not within the window after
    GlobalToLocal().
    Any ideas what could cause this behaviour?


    I realise that all these questions I'm posting should not have to be asked,
    but where can I find proper doentation on using Appearance Manager? I'm
    working dry with the OS 8 Reference Manual PDF and the Appearance SDK which
    are both severely lacking in illustrated examples. The sample software only
    does the minimum to display controls and all the important calls have been
    "wrapped away".
    Hasn't anybody written anything about using Appearance Manager since 1997?



    Graham Hinton Guest

  2. #2

    Default Re: Help with Popup Menus in Windows (OS 9 Appearance)

    In article <BB2F7C1A96687C22Chinton.demon.co.uk>,
    [email]hitmanspammer.deathsquad.com[/email] (Graham Hinton) wrote:
    > I have a window with a popup menu that can open any of five dialogs, all
    > that is working, BUT if I open one, select the window and open another and
    > then close it the popup no longer works correctly.
    The problem is that you have multiple controls (in multiple windows)
    referring to a single menu. When the 2nd dialog is closed, the menus
    are removed from the menu bar.

    To avoid this problem, load the menus into the menu bar by hand BEFORE
    creating the first dialog. When this happens, the popup menu control
    will note that the menus are already in the menu bar and not
    install/remove them for you.

    aMenu = GetMenu(menuID1)
    InsertMenu(aMenu, -1)
    Tom Dowdy Guest

  3. #3

    Default Re: Help with Popup Menus in Windows (OS 9 Appearance)

    In article <BB2F7C1A96687C22Chinton.demon.co.uk>,
    [email]hitmanspammer.deathsquad.com[/email] (Graham Hinton) wrote:

    [snip]
    >
    > I have a window with a popup menu that can open any of five dialogs, all
    > that is working, BUT if I open one, select the window and open another and
    > then close it the popup no longer works correctly.
    >
    > My window comes to the front and is activated as it should be, but clicking
    > on the popup does not open the menu! FindControl is returning zero in this
    > condition. If I click on the first dialog and then on the window again the
    > popup works again.
    Sounds like a problem with your window activation code and/or your modeless
    dialog handler(s)...
    > This does not happen with one dialog & window, only if I open more than one
    > and close the last leaving the window in front.
    > All the dialogs are modeless and closed with HideWindow(). I know my window
    > is in front and I get the mouseDown inContent click and I call FindControl
    > explicitly with that window's pointer, but it returns zero for the part and
    > the control handle, like this:
    >
    > if ( wp == Keeper )
    I'm assuming that Keeper is either a local or global variable.
    Any chance it the value isn't always what you expect? I use

    if ( (wp == Keeper) && (wp != 0L) )
    > {
    > Point position;
    > ControlHandle control;
    > ControlPartCode code;
    > SInt16 part;
    >
    > position = event->where;
    > GlobalToLocal( &position );
    Did you check the value of position.h, .v in the debugger? If you click
    on the control and the local coords are NOT what you expect, then you need
    to look at your window activation/deactivation handling.
    > part = FindControl( position, Keeper, &control );
    I believe strongly in defensive programming. Here, I'd explicitly
    initialise both part and control. I know that doesn't necessarily
    help solve your problem, but it makes debugging a whole lot easier!!
    (You could do this at the start of your code block above, in the
    declaration statements)

    part = 0;
    control = NIL;
    part = FindControl( position, Keeper, &control );
    > // control = FindControlUnderMouse( position, Keeper, &part );
    > if ( control == _keeper_popup )
    There's a couple of things you could do here to make debugging easier.
    One is to make sure you assign unique control reference id's to every
    control. You can keep track of these using #define's or enum's in a
    header file. This allows an additional check on the validity (or
    otherwise) of FindControl, etc.

    You should also check the value of part - if it's zero, you know
    there's a problem before heading any further.

    if ( part != 0 )
    part = TrackControl( control, position, NIL); // track click on ctrl

    if ( part != 0 ) { // ok, real click on ctrl, now process it

    }
    > {
    > if ( TrackControl( control, position, NIL) )
    > // code = HandleControlClick( control, position,
    event->modifiers, NIL );
    > // if ( code != kControlNoPart )
    > Do_Popup_Check( );
    > }
    > }
    >
    > I think I'm getting an incorrect mouse position, even if I close with Cmd-W
    > ie without a click, the coordinates are not within the window after
    > GlobalToLocal().
    > Any ideas what could cause this behaviour?
    Ah. Check your window (de)activation procedures. You must be missing
    something there. For whatever reason, the GrafPort/GWorld is not being set
    correctly when you switch windows. Check the docs on the Event and Window
    managers, for starters.
    >
    > I realise that all these questions I'm posting should not have to be asked,
    > but where can I find proper doentation on using Appearance Manager? I'm
    > working dry with the OS 8 Reference Manual PDF and the Appearance SDK which
    > are both severely lacking in illustrated examples. The sample software only
    > does the minimum to display controls and all the important calls have been
    > "wrapped away".
    > Hasn't anybody written anything about using Appearance Manager since 1997?
    [sings] The API, it is a'changin'....
    David Stone Guest

  4. #4

    Default Re: Help with Popup Menus in Windows (OS 9 Appearance)

    In article <BB3A48C1966833C482hinton.demon.co.uk>,
    [email]hitmanspammer.deathsquad.com[/email] (Graham Hinton) wrote:
    > In article <spam-0907031125390001csgmac.chem.utoronto.ca>,
    > [email]spamaddress.inva[/email]lid (David Stone) wrote:
    >
    > Does redrawing a part of the other deactivated Dialog change the GrafPort?
    > Was I being too naive expecting the OS to save my current port? I thought
    > controls in a dialog were supposed to be low maintenance?
    Since the headline says OS 9 Appearance, I guess you're not using Carbon
    events. And in that case, yes, you're responsible for setting up the
    port correctly when handling clicks in windows or when drawing in a
    window. If you want to learn the details, I'd suggest Apple's very
    well-written books "Inside Macintosh: Mac Toolbox Essentials" and
    "Inside Macintosh: Imaging with Quickdraw", which very comprehensibly
    detail what the Window and Control managers do for you, and what's your
    responsibility.

    Cheers,
    -- M. Uli Kusterer
    [url]http://www.zathras.de[/url]
    Uli Kusterer Guest

Similar Threads

  1. Popup Menus
    By Bill Jaynes in forum Macromedia Dynamic HTML
    Replies: 11
    Last Post: October 18th, 03:10 PM
  2. Customized popup window appearance?
    By rhennigar webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 1
    Last Post: December 12th, 09:08 AM
  3. help with popup menus.
    By aKem webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 2
    Last Post: August 13th, 05:15 AM
  4. Popup menus and issues
    By djsamisam webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 2
    Last Post: July 23rd, 10:22 PM
  5. Popup Menus and Templates
    By Jared in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 16th, 11:28 AM

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