NSView clickable area

  • Hi,

    my NSView in the Statusitem bar does not get mouse events on areas which
    are transparent. Users are complaining about this.

    If you want to know how the bahavior is, just thing about if you click
    on the menubar clock and the menu there would only open if you hit the
    black text. If you hit the space between the letters or inside the
    letters, you won't open the menu.

    How do I make a NSView to handle events on the whole size?
    And how does the system know where I don't have it transparent?

    Seems like if I draw it all in red using fillrect, I get all events I
    expect. But if there is just a small icon, the space around is ignored.
    Somehow the system seems to thing it needs to watch on the alpha mask.

    Gruß
    Christian

    --
    Over 900 classes with 17000 functions in one REALbasic plug-in.
    The Monkeybread Software Realbasic Plugin v7.6.

    <http://www.monkeybreadsoftware.de/realbasic/plugins.shtml>
  • On Nov 17, 2007, at 10:30 PM, Christian Schmitz wrote:

    > Hi,
    >
    > my NSView in the Statusitem bar does not get mouse events on areas
    > which
    > are transparent. Users are complaining about this.
    >
    > If you want to know how the bahavior is, just thing about if you click
    > on the menubar clock and the menu there would only open if you hit the
    > black text. If you hit the space between the letters or inside the
    > letters, you won't open the menu.
    >
    > How do I make a NSView to handle events on the whole size?
    > And how does the system know where I don't have it transparent?
    >
    > Seems like if I draw it all in red using fillrect, I get all events I
    > expect. But if there is just a small icon, the space around is
    > ignored.
    > Somehow the system seems to thing it needs to watch on the alpha mask.

    Well pretty much all of Mac OS X hit detection works considering
    opacity. I bet you can use a white fill at like 5% or a little more to
    get the OS to do the hit detection you want without making it visible
    to the user.

    Note on Leopard I don't see this behavior nor do I recall it on Tiger
    but I will take your word for it.

    -Shawn
  • Shawn Erickson <shawnce...> wrote:

    > Well pretty much all of Mac OS X hit detection works considering
    > opacity. I bet you can use a white fill at like 5% or a little more to
    > get the OS to do the hit detection you want without making it visible
    > to the user.

    I found that work around, but I'm still looking for the root of this
    problem.

    When I copy this code:

    NSStatusBar *statusbar=[NSStatusBar systemStatusBar];
    NSStatusItem* menuItem=[statusbar statusItemWithLength:-1];

    if (menuItem)
            {
            [menuItem retain];
            [menuItem setTitle:@"Test"];
            [menuItem setHighlightMode:YES];
            }

    to my app or to a new cocoa app in Xcode it will work in the Cocoa app,
    but fail in my app. This opacity hit testing seems to be off by default
    and something switches it on for my application in some of the other
    frameworks, but I have no idea on how they do it and on what to look for
    to fix it.

    Gruß
    Christian

    --
    Over 900 classes with 17000 functions in one REALbasic plug-in.
    The Monkeybread Software Realbasic Plugin v7.6.

    <http://www.monkeybreadsoftware.de/realbasic/plugins.shtml>
  • Does the -[NSView hitTest:] method shed any light on the situation?

    Mike.

    On 18 Nov 2007, at 07:12, Christian Schmitz wrote:

    > Shawn Erickson <shawnce...> wrote:
    >
    >> Well pretty much all of Mac OS X hit detection works considering
    >> opacity. I bet you can use a white fill at like 5% or a little more
    >> to
    >> get the OS to do the hit detection you want without making it visible
    >> to the user.
    >
    > I found that work around, but I'm still looking for the root of this
    > problem.
    >
    > When I copy this code:
    >
    >
    > NSStatusBar *statusbar=[NSStatusBar systemStatusBar];
    > NSStatusItem* menuItem=[statusbar statusItemWithLength:-1];
    >
    > if (menuItem)
    > {
    > [menuItem retain];
    > [menuItem setTitle:@"Test"];
    > [menuItem setHighlightMode:YES];
    > }
    >
    > to my app or to a new cocoa app in Xcode it will work in the Cocoa
    > app,
    > but fail in my app. This opacity hit testing seems to be off by
    > default
    > and something switches it on for my application in some of the other
    > frameworks, but I have no idea on how they do it and on what to look
    > for
    > to fix it.
    >
    > Gruß
    > Christian
    >
    > --
    > Over 900 classes with 17000 functions in one REALbasic plug-in.
    > The Monkeybread Software Realbasic Plugin v7.6.
    >
    > <http://www.monkeybreadsoftware.de/realbasic/plugins.shtml
previous month november 2007 next month
MTWTFSS
      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    
Go to today