Skip navigation.
 
mlRe: ToolTip like info item
FROM : Bertrand Mansion
DATE : Sun Nov 03 18:11:51 2002

<<email_removed>> wrote :

> On Saturday, November 2, 2002, at 05:24  PM, Bertrand Mansion wrote:
>

>> Hi again :)
>>
>> In the rulers example found in AppKit examples, I have noticed that
>> NSRulerView displays some kind of tooltip to show units when the
>> markers are
>> moved.
>>
>> I would like to have the same kind of items in my view (just a standard
>> NSView though). I thought about using tooltips but they don't fit my
>> needs
>> because of their delay. Indeed, I need this item to be here all the
>> time and
>> to be dynamically updated, showing the cursor x, y position.
>>
>> This is a bit like in the Grab app but with a tooltip look and feel
>> (shadow
>> included). Is such an item available in cocoa or will I have to
>> implement
>> something approaching ?
>>
>> If so, what do you think would be the best way to go ?
>>
>> Thank you for any hints,

>
> I'd make an NSWindow category similar to this....
>
> @implementation NSWindow(TooltipLike)
> + (NSWindow *)tooltipLikeWindowWithContentRect:(NSRect)someRect
> {
> NSWindow *yourWindow = [[NSWindow alloc] initWithContentRect:someRect
> styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained
> defer:YES];
>
> // This seems "proper", may want a diff. level though..
>    [yourWindow setLevel:NSStatusWindowLevel];
>
> // Mouse events aren't needed, most likely...
>    [yourWindow setIgnoresMouseEvents:YES];
>
>    // Tooltips are more of a toned-down peachy-yellow I think.
>    // This will be bright, I just know it. ;-)
>    [yourWindow setBackgroundColor: [NSColor yellowColor] ];
>
>    // ?
>    [yourWindow setAlphaValue:0.8];
>
> return [yourWindow autorelease];
> }
> @end
>
>
> NSWindow *test = [NSWindow
> tooltipLikeWindowWithContentRect:NSMakeRect(0,0,60,20)];
> [test retain];
>
> // myView = NSTexField with the line border for the tooltip-ish look..?
>
> [test setContentView: myView];
> [myView setStringValue:@"good?"];
> [test orderFront:nil];
>
> Anyway, good luck and I hope that helps! :-)


Thanks Ryan, that's great :)
I was actually starting to do the same thing but with an NSPanel. Using
notifications and [[self window] setAcceptsMouseMovedEvents: YES]; , I could
follow the position of my cursor.

I was going to try to figure out how to write some info in this fake
tooltip. Thanks for the answer, you read my mind.

Bertrand Mansion
Mamasam
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlToolTip like info item Bertrand Mansion Nov 3, 02:24
mlRe: ToolTip like info item Ryan Stevens Nov 3, 17:26
mlRe: ToolTip like info item Bertrand Mansion Nov 3, 18:11