Scrolling text in Status Item

  • I need to create an NSStatusItem which displays a bit of horizontally
    scrolling text, much like the messages the airport menu extra
    displays about connection status and so on.

    My hunch is that the best approach is to create a View-based
    NSStatusItem with a static width, and do some sort of animation with
    the text. I've never done anything like this, though, so any advice,
    pointers, samples would be really helpful.

    thanks

    -e
  • hai

    i think you can break the text with "\n" and then you can read the
    height from text to resize your view or textfield....

    i don't know...

    best regards

    philippe
    Am 08.10.2006 um 20:48 schrieb Eric Blanpied:

    > I need to create an NSStatusItem which displays a bit of
    > horizontally scrolling text, much like the messages the airport
    > menu extra displays about connection status and so on.
    >
    > My hunch is that the best approach is to create a View-based
    > NSStatusItem with a static width, and do some sort of animation
    > with the text. I've never done anything like this, though, so any
    > advice, pointers, samples would be really helpful.
    >
    > thanks
    >
    > -e
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/my-mailing%
    > 40treeinspired.ch
    >
    > This email sent to <my-mailing...>
  • Thanks, but it sounds like you're providing advice on sizing the
    view, while what I'm really interested in is advice about animating
    (scrolling right-to left) text in the menubar, presumably in a view.

    Does anyone have any pointers?

    thanks

    -e

    On Oct 8, 2006, at 12:00 pm, Philippe Heinrich Regenass wrote:

    > hai
    >
    > i think you can break the text with "\n" and then you can read the
    > height from text to resize your view or textfield....
    >
    > i don't know...
    >
    > best regards
    >
    > philippe
    > Am 08.10.2006 um 20:48 schrieb Eric Blanpied:
    >
    >> I need to create an NSStatusItem which displays a bit of
    >> horizontally scrolling text, much like the messages the airport
    >> menu extra displays about connection status and so on.
    >>
    >> My hunch is that the best approach is to create a View-based
    >> NSStatusItem with a static width, and do some sort of animation
    >> with the text. I've never done anything like this, though, so any
    >> advice, pointers, samples would be really helpful.
    >>
    >> thanks
    >>
    >> -e
    >> _______________________________________________
    >> Do not post admin requests to the list. They will be ignored.
    >> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >> Help/Unsubscribe/Update your Subscription:
    >> http://lists.apple.com/mailman/options/cocoa-dev/my-mailing%
    >> 40treeinspired.ch
    >>
    >> This email sent to <my-mailing...>
    >
  • OK, I've got the scrolling text working well in my NSStatusItem. I
    used setView to set a custom view, drew the text into an image an
    then used compositeToPoint: fromRect: to animate the text.

    Now, I need to make the NSStatusItem drop a menu when clicked, and
    that's got me stumped. It seems that when you use setView: you give
    up on ALL the menu behavior. Even using setMenu: and then
    popUpStatusItemMenu: won't make a menu appear. If I leave out the
    setView: call it works fine. It's as if you get to use either
    setView: or setMenu:, but not both.

    Any advice?

    thanks

    -eric

    On Oct 8, 2006, at 12:43 pm, Eric Blanpied wrote:

    > Thanks, but it sounds like you're providing advice on sizing the
    > view, while what I'm really interested in is advice about animating
    > (scrolling right-to left) text in the menubar, presumably in a view.
    >
    > Does anyone have any pointers?
    >
    > thanks
    >
    > -e
    >
    > On Oct 8, 2006, at 12:00 pm, Philippe Heinrich Regenass wrote:
    >
    >> hai
    >>
    >> i think you can break the text with "\n" and then you can read the
    >> height from text to resize your view or textfield....
    >>
    >> i don't know...
    >>
    >> best regards
    >>
    >> philippe
    >> Am 08.10.2006 um 20:48 schrieb Eric Blanpied:
    >>
    >>> I need to create an NSStatusItem which displays a bit of
    >>> horizontally scrolling text, much like the messages the airport
    >>> menu extra displays about connection status and so on.
    >>>
    >>> My hunch is that the best approach is to create a View-based
    >>> NSStatusItem with a static width, and do some sort of animation
    >>> with the text. I've never done anything like this, though, so any
    >>> advice, pointers, samples would be really helpful.
    >>>
    >>> thanks
    >>>
    >>> -e
    >>> _______________________________________________
    >>> Do not post admin requests to the list. They will be ignored.
    >>> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >>> Help/Unsubscribe/Update your Subscription:
    >>> http://lists.apple.com/mailman/options/cocoa-dev/my-mailing%
    >>> 40treeinspired.ch
    >>>
    >>> This email sent to <my-mailing...>
    >>
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<ericb...>
    >
    > This email sent to <ericb...>
  • I don't have any advice, Eric.

    But I'd really, really like to know if anyone knows how Apple puts the
    pop-down slider in the volume control menubar item.

    Because if someone could tell me how that's done, I might be able to
    finish my idea of having a menubar item (an NSStatusItem, actually)
    pop-down a textview with some text in it when the user clicks on it.

    -m

    On 10/9/06, Eric Blanpied <ericb...> wrote:
    > OK, I've got the scrolling text working well in my NSStatusItem. I
    > used setView to set a custom view, drew the text into an image an
    > then used compositeToPoint: fromRect: to animate the text.
    >
    > Now, I need to make the NSStatusItem drop a menu when clicked, and
    > that's got me stumped. It seems that when you use setView: you give
    > up on ALL the menu behavior. Even using setMenu: and then
    > popUpStatusItemMenu: won't make a menu appear. If I leave out the
    > setView: call it works fine. It's as if you get to use either
    > setView: or setMenu:, but not both.
    >
    > Any advice?
    >
    > thanks
    >
    > -eric
    >
    > On Oct 8, 2006, at 12:43 pm, Eric Blanpied wrote:
    >
    >> Thanks, but it sounds like you're providing advice on sizing the
    >> view, while what I'm really interested in is advice about animating
    >> (scrolling right-to left) text in the menubar, presumably in a view.
    >>
    >> Does anyone have any pointers?
    >>
    >> thanks
    >>
    >> -e
    >>
    >> On Oct 8, 2006, at 12:00 pm, Philippe Heinrich Regenass wrote:
    >>
    >>> hai
    >>>
    >>> i think you can break the text with "\n" and then you can read the
    >>> height from text to resize your view or textfield....
    >>>
    >>> i don't know...
    >>>
    >>> best regards
    >>>
    >>> philippe
    >>> Am 08.10.2006 um 20:48 schrieb Eric Blanpied:
    >>>
    >>>> I need to create an NSStatusItem which displays a bit of
    >>>> horizontally scrolling text, much like the messages the airport
    >>>> menu extra displays about connection status and so on.
    >>>>
    >>>> My hunch is that the best approach is to create a View-based
    >>>> NSStatusItem with a static width, and do some sort of animation
    >>>> with the text. I've never done anything like this, though, so any
    >>>> advice, pointers, samples would be really helpful.
    >>>>
    >>>> thanks
    >>>>
    >>>> -e
    >>>> _______________________________________________
    >>>> Do not post admin requests to the list. They will be ignored.
    >>>> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >>>> Help/Unsubscribe/Update your Subscription:
    >>>> http://lists.apple.com/mailman/options/cocoa-dev/my-mailing%
    >>>> 40treeinspired.ch
    >>>>
    >>>> This email sent to <my-mailing...>
    >>>
    >>
    >> _______________________________________________
    >> Do not post admin requests to the list. They will be ignored.
    >> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >> Help/Unsubscribe/Update your Subscription:
    >> http://lists.apple.com/mailman/options/cocoa-dev/<ericb...>
    >>
    >> This email sent to <ericb...>
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<soundflower.dev...>
    m

    >
    > This email sent to <soundflower.dev...>
    >
  • Hi guys,

    Eric: I suggest you try NSMenu's

    + (void)popUpContextMenu:(NSMenu *)*menu*
    withEvent:(NSEvent<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
    sses/NSEvent_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSEvent
    >*)
    *event* forView:(NSView<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
    sses/NSView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSView
    >*)
    *view.

    *You can put that in mouseDown or some such place and pass in the event.

    You can't use both a menu and a view, Apple's docs say so. When you setView
    it gives you complete control over the item and disables all other actions
    and drawing methods.

    Mercer: I too wanted to know how this was done, quite some time ago, so I
    contacted Apple directly. Here is a snippet from the code I recieved, it
    should be all you need.

    // This was in awakeFromNib:
    //
    // mVolumeBox is just a NSBox surounding the volume slider
    //
    [mVolumeButton sendActionOn:NSLeftMouseDownMask];

        // Add tracking rect so that -mouseEntered and -mouseExited are called
        [mVolumeBox addTrackingRect:[mVolumeBox bounds] owner:self userData:nil
    assumeInside:NO];

    - (IBAction) showVolumeWindow:(id)sender
    {
        NSRect  buttonFrame;        // Frame of mVolumeButton in window
    coordinates
        NSRect  windowFrame;        // Frame of mVolumeWindow in screen
    coordinates

        // Position the volume window near the volume button
        buttonFrame = [mVolumeButton convertRect:[mVolumeButton bounds]
    toView:nil];
        windowFrame = [mVolumeWindow frame];
        windowFrame.origin = [[mVolumeButton window] convertBaseToScreen:
    buttonFrame.origin];
        [mVolumeWindow setFrame:windowFrame display:YES];

        // Show window
        [self makeWindowVisibleAtFullAlpha];
    }

    - (void) mouseEntered:(NSEvent*)event
    {
        [self makeWindowVisibleAtFullAlpha];
    }

    - (void) mouseExited:(NSEvent*)event
    {
        [self startFadeOutTimerWithDuration:0.75];
    }

    - (void) makeWindowVisibleAtFullAlpha
    {
        [self setFadeOutTimer:nil withStartTime:0 duration:0];
        [mVolumeWindow setAlphaValue:1.0];
        [mOwnerWindow addChildWindow:mVolumeWindow ordered:NSWindowAbove];
        [mVolumeWindow orderFront:self];
    }

    That should do it. You probably don't need all of the above code.

    Good luck guys!
    Peace, Alan

    --
    // Quotes from yours truly -------------------------
    "You don't forget, you just don't remember."
    "Maturity resides in the mind."
    "Silence is the Universe's greatest gift."
    "When the World realizes that religion really is unimportant, then it shall
    evolve."
previous month october 2006 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