Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

widgetman

macrumors member
Original poster
Oct 7, 2004
39
0
i am working on a small project that uses webkit. i want to change the text in an NSTextField to be the location of where a link will lead. that was confusing, so ill give an example of what im talking about. If im on apple's website and i move my cursor over the button at the top that says "store", the status bar at the bottom of the browser window says "http://www.apple.com/store/", even though i havent clicked the link yet. how do i get the location of the link under the cursor and display it in a textfield?
 

grabberslasher

macrumors 6502
Aug 2, 2002
409
1
Éire
widgetman said:
i am working on a small project that uses webkit. i want to change the text in an NSTextField to be the location of where a link will lead. that was confusing, so ill give an example of what im talking about. If im on apple's website and i move my cursor over the button at the top that says "store", the status bar at the bottom of the browser window says "http://www.apple.com/store/", even though i havent clicked the link yet. how do i get the location of the link under the cursor and display it in a textfield?

Sorry for bringing up an old thread. I use this (put under the rest of your webView code in your file):


Code:
- (void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(unsigned int)modifierFlags
{
	
	NSString*   URLString;
	URLString = [[elementInformation objectForKey:WebElementLinkURLKey] absoluteString];

	if (!URLString)
	{
		[statusBarTextField setEditable:TRUE];
		[statusBarTextField setTitleWithMnemonic:@""];
		[statusBarTextField setEditable:FALSE];
	}
	else
	{
		[statusBarTextField setEditable:TRUE];
		[statusBarTextField setTitleWithMnemonic:[[@"Go to \"" stringByAppendingString:URLString] stringByAppendingString:@"\""]];
		[statusBarTextField setEditable:FALSE];
	}
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.