• 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: SA Dev <email@hidden>
  • Date: Tue, 19 Jul 2005 11:05:15 -0400


Yes, you need to use the -initWithFrame: designated initializer for NSView. Using -init gives you a view with NSZeroRect and I think a few other key things are not properly initialized as well.


I strongly suggest reading the docs on NSView - this is vital information you need to understand if you're going to subclass NSView. You can determine the size based on the toolbar's current size (read the docs on NSToolbar).



On Jul 19, 2005, at 11:02 AM, Luc Vandal wrote:

That's what I did! The item displays just fine but I never get any mouse-related events, even though I did override them. Do I need to init the NSView with a frame? If so, how can I determine the size of that frame?

Luc


On 19-Jul-05, at 10:46 AM, SA Dev wrote:



No sample code needed, really. If you understand subclassing an NSView and overriding the mouse-related methods (such as - mouseEntered:) to fire your own code, you're half-way there.


Just create an NSToolbarItem as you normally would, but create an instance of your custom view and use the -setView: method. You have to make sure the size is correct so things don't get clipped, etc.

If you have a specific question, I'm sure the list will respond with a specific answer. Also, the whole "GIYF" (google is your friend) principle works well here - there's probably a wealth of examples in the list archives.



On Jul 19, 2005, at 10:35 AM, Luc Vandal wrote:


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:
40visuaide.com


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:
40silentalcove.net


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:
40silentalcove.net


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:
40silentalcove.net


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
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>)
 >Re: tooltip event/notification? (From: Luc Vandal <email@hidden>)
 >Re: tooltip event/notification? (From: SA Dev <email@hidden>)
 >Re: tooltip event/notification? (From: Luc Vandal <email@hidden>)

  • Prev by Date: Re: NSFileManager - "Can't read directory contents" ??
  • Next by Date: Re: NSFileManager - "Can't read directory contents" ??
  • Previous by thread: Re: tooltip event/notification?
  • Next by thread: CoreData: Editing a model with XCode corrupts reflefive relationships
  • Index(es):
    • Date
    • Thread