PDA

View Full Version : webkit link question




widgetman
Feb 11, 2005, 11:10 PM
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
Mar 5, 2005, 10:32 AM
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):



- (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];
}
}