• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: tooltip event/notification?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tooltip event/notification?


  • Subject: Re: tooltip event/notification?
  • From: Luc Vandal <email@hidden>
  • Date: Tue, 19 Jul 2005 10:35:52 -0400

Does anyone has a code sample for using NSView with NSToolbarItem? I'm having a hard time with this...!!!

Luc


On 19-Jul-05, at 9:33 AM, SA Dev wrote:


You could use a custom NSView and use NSToolbarItem's -setView: ...



On Jul 19, 2005, at 9:22 AM, Luc Vandal wrote:

Thanks! While this code is really helpful, I still need to know when the mouse cursor is over a toolbar button. Does anyone know how that could be done?

Thanks!

Luc

On 18-Jul-05, at 10:04 PM, Shaun Wexler wrote:


On Jul 18, 2005, at 12:56 PM, Luc Vandal wrote:


I have a toolbar and each item has a tooltip. Is there a way to know when a tooltip will be displayed? I need to know because our application has to speak and say the tooltip's content. In our case, we cannot use the accessibility stuff.


I needed an enhancement so users could disable tooltips entirely. I added an item to the main menu Help "View Tool Tips", which is checked by default (you can use bindings). It tweaks a private AppKit subclass, but it's safe and works fine thru Tiger. I just modified it for speech (disclaimer, untested, written in Mail.app)...


//
//  SKWBase_NSToolTipManager
//  SKWBase
//
//  Created by Shaun Wexler on 6/21/04.
//  Copyright (c) 2004 SKW Development. All rights reserved.
//

static BOOL toolTipsEnabled = YES;
static BOOL speaksToolTips = NO;

@interface NSApplication (SKWToolTipAdditions)

- (BOOL)toolTipsEnabled;
- (void)setToolTipsEnabled:(BOOL)enabled;
- (BOOL)speaksToolTips;
- (void)setSpeaksToolTips:(BOOL)speaks;

@end

@implementation NSApplication (SKWToolTipAdditions)

- (BOOL)toolTipsEnabled
{
    return toolTipsEnabled;
}

- (void)setToolTipsEnabled:(BOOL)enabled
{
toolTipsEnabled = enabled;
[[NSUserDefaults standardUserDefaults] setBool:!enabled forKey:@"SKWToolTipsDisabled"];
}


- (BOOL)speaksToolTips
{
    return speaksToolTips;
}

- (void)setSpeaksToolTips:(BOOL)speaks
{
speaksToolTips = speaks;
[[NSUserDefaults standardUserDefaults] setBool:speaks forKey:@"SKWToolTipsSpeechEnabled"];
}


@end

@interface NSToolTip : NSObject
{
    NSView *view;
    NSCell *cell;
    NSString *string;
    id owner;
    void *data;
    int trackingNum;
    BOOL ownerIsDisplayDelegate;
    struct _NSRect trackingRect;
}

- (void)dealloc;
- (id)description;

@end

@interface NSToolTipManager : NSObject
{
    NSWindow *toolTipWindow;
    NSMutableArray *toolTips;
    double toolTipDelay;
    NSDate *timeToolTipRemovedFromScreen;
    CFRunLoopTimerRef toolTipDisplayTimer;
    NSToolTip *currentDisplayedToolTip;
    NSToolTip *currentFadingToolTip;
    float currentFadeValue;
    NSTimer *fadeTimer;
    NSWindow *lastToolTipWindow;
}

- (void)displayToolTip:(id)toolTip;

@end

@interface SKWToolTipManager : NSToolTipManager

- (void)displayToolTip:(id)toolTip;

@end

@implementation SKWToolTipManager

+ (void)load
{
Class toolTipManagerClass = NSClassFromString(@"NSToolTipManager");
if (toolTipManagerClass != Nil) {
[self poseAsClass:toolTipManagerClass];
toolTipsEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"SKWToolTipsDisabled"];
speaksToolTips = [[NSUserDefaults standardUserDefaults] boolForKey:@"SKWToolTipsSpeechEnabled"];
}
}


static NSSpeechSynthesizer *speechSynthesizer = nil;

- (void)displayToolTip:(id)toolTip
{
    if ([NSApp toolTipsEnabled]) {
        [super displayToolTip:toolTip];
    }
    if ([NSApp speaksToolTips]) {
        if (!speechSynthesizer) {
            speechSynthesizer = [[NSSpeechSynthesizer alloc] init];
            [speechSynthesizer setDelegate:self];
        }
        [speechSynthesizer startSpeakingString:toolTip->string];
    }
}

- (void)orderOutToolTip
{
    [speechSynthesizer stopSpeaking];
}

- (void)abortToolTip
{
    [speechSynthesizer stopSpeaking];
}

- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedSpeaking
{
if (finishedSpeaking && sender == speechSynthesizer) {
speechSynthesizer = nil;
[sender release];
}
}


@end

-- Shaun Wexler
MacFOH
http://www.macfoh.com


My amp goes to eleven.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: tooltip event/notification?
      • From: SA Dev <email@hidden>
References: 
 >tooltip event/notification? (From: Luc Vandal <email@hidden>)
 >Re: tooltip event/notification? (From: Shaun Wexler <email@hidden>)
 >Re: tooltip event/notification? (From: Luc Vandal <email@hidden>)
 >Re: tooltip event/notification? (From: SA Dev <email@hidden>)

  • Prev by Date: Re: Display Rich Text Encoding within plain text
  • Next by Date: Re: tooltip event/notification?
  • Previous by thread: Re: tooltip event/notification?
  • Next by thread: Re: tooltip event/notification?
  • Index(es):
    • Date
    • Thread