Re: Creating a clickable (web-browser-like) URL control
Re: Creating a clickable (web-browser-like) URL control
- Subject: Re: Creating a clickable (web-browser-like) URL control
- From: Dan Wood <email@hidden>
- Date: Tue, 06 Aug 2002 11:34:09 -0700
I missed the first part of this, so I'm not sure if you wanted to have
a link embedded within a bunch of non-link text -- in which case, I
think that the NSTextView, shifted slightly and turned to transparent
(I think with setDrawsBackground?) will do the trick -- this is how I
used to do it. But if all you want is a link, just use a button with
the title being your URL to click on, and set the hyperlink attribute
programatically (since it has to be plain black in interface builder.)
so I'll do something like:
[oButton setAttributedTitle:
[theURLString hyperlink]];
... where hyperlink is an NSString category method:
- (NSAttributedString *)hyperlink
{
NSDictionary *attributes
= [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:NSSingleUnderlineStyle],
NSUnderlineStyleAttributeName,
self,NSLinkAttributeName, // link to self
[NSFont systemFontOfSize:[NSFont smallSystemFontSize]],
NSFontAttributeName,
[NSColor colorWithCalibratedRed:0.1 green:0.1 blue:1.0 alpha:1.0],
NSForegroundColorAttributeName,
nil];
NSAttributedString *result
= [[[NSAttributedString alloc]
initWithString:self
attributes:attributes] autorelease];
return result;
}
On Tuesday, August 6, 2002, at 09:02 AM, John Anderson wrote:
Not sure about #1... maybe you can move your layout a few pixels to
make it line up? Hacky but it would work...
John
On Monday, August 5, 2002, at 08:03 AM, Sean McBride wrote:
John Anderson (email@hidden) wrote:
The best way would be to create an NSTextView and populate its
contents
dynamically.
(snip)
That should display a clickable link.
It does thanks! But there are some visual problems:
1) The background. After playing around with IB a lot, I managed to
drag
the border from a default NSTextField to my NSTextView. In IB it
looks
perfect but when I actually run my pref pane the striped background
of my
NSTextView does not line up with the window's striped background. :(
2) The link is only clickable if the 'selectable' attribute is on,
causing an insertion point cursor to appear on rollover.
I think there's even a way to
make NSTextView display the finger cursor over the link. Don't
remember
off-hand.
This would solve #2. I'll see if I can find an apropriate method...
But problem #1 is the real killer, any ideas?
Thanks again!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
--
Dan Wood
Karelia Software, LLC
email@hidden
http://www.karelia.com/
Watson for Mac OS X:
http://www.karelia.com/watson/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.