Highlighting NSView used in NSStatusItem

  • I've figured out how to get my menu working when using an NSView in
    an NSStatusItem, but I can't figure out how to get the view to
    highlight when clicked. Yes, I've checked the archives and google,
    but I can't find anything like what I'm doing. So if someone has any
    pointers, I'd appreciate it thanks.

    "Human beings are the only creatures that allow their children to
    come back home."
    --Bill Cosby

    Lorenzo Thurman
    <lorenzo...>
  • > someone has any pointers,
    >
    Your custom view is responsible for drawing itself and providing its
    own behaviors, such as processing mouse clicks and sending action
    messages.

    Override  the NSResponder's - (void)mouseDown:(NSEvent *)theEvent and
    provide the necessary behavior.

    - Apparao.

    On Oct 12, 2007, at 8:40 AM, Lorenzo Thurman wrote:

    > I've figured out how to get my menu working when using an NSView in
    > an NSStatusItem, but I can't figure out how to get the view to
    > highlight when clicked. Yes, I've checked the archives and google,
    > but I can't find anything like what I'm doing. So if someone has
    > any pointers, I'd appreciate it thanks.
    >
    > "Human beings are the only creatures that allow their children to
    > come back home."
    > --Bill Cosby
    >
    > Lorenzo Thurman
    > <lorenzo...>
    >
  • > Your custom view is responsible for drawing itself and providing its own
    > behaviors, such as processing mouse clicks and sending action messages.
    >
    > Override  the NSResponder's - (void)mouseDown:(NSEvent *)theEvent and
    > provide the necessary behavior.
    >
    > - Apparao.
    >
    > On Oct 12, 2007, at 8:40 AM, Lorenzo Thurman wrote:
    >
    >> I've figured out how to get my menu working when using an NSView in an
    >> NSStatusItem, but I can't figure out how to get the view to highlight
    >> when clicked. Yes, I've checked the archives and google, but I can't
    >> find anything like what I'm doing. So if someone has any pointers, I'd
    >> appreciate it thanks.
    >>
    >> "Human beings are the only creatures that allow their children to come
    >> back home."
    >> --Bill Cosby
    >>
    >> Lorenzo Thurman
    >> <lorenzo...>
    Thanks for the reply, but I guess what the necessary behavior is, is at
    least part of my question. I already override mouseDown
    to get the menu to display. I tried using drawing routines to fill the
    view's rect with the systemhiglight color as a part of mouseDown, but
    that came out looking pretty awful. What I got was my view being
    completely overwhelmed by the hightlight color (which wasn't the correct
    color anyway). The text which is part of my view did not 'invert' its
    color and the view's image was completely obscured.
  • > Thanks for the reply, but I guess what the necessary behavior is, is at
    > least part of my question. I already override mouseDown
    > to get the menu to display. I tried using drawing routines to fill the
    > view's rect with the systemhiglight color as a part of mouseDown, but
    > that came out looking pretty awful. What I got was my view being
    > completely overwhelmed by the hightlight color (which wasn't the correct
    > color anyway). The text which is part of my view did not 'invert' its
    > color and the view's image was completely obscured.

      Your problem is that you are simply not reading the manual. All
    drawing should be done in (or called from) the -drawRect: method.
    Randomly drawing at arbitrary times is a bad idea.

      Read this: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide
    /Introduction/chapter_1_section_1.html


      ... and this:
    http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/Mou
    seTrackingEvents/chapter_7_section_2.html


      ... and keep in mind that you need to set a state when the mouse
    enters/exits/moves/whatever, then flag your view as needing display
    (per the first link I sent you). When -drawRect: is called, you'll
    draw your view based on the current states.

    --
    I.S.
previous month october 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 31        
Go to today