webkit link question

Discussion in 'Mac Programming' started by widgetman, Feb 11, 2005.

  1. macrumors member

    Joined:
    Oct 7, 2004
    #1
    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?
     
  2. macrumors 6502

    Joined:
    Aug 2, 2002
    Location:
    Éire
    #2
    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];
    	}
    }
    
     

Share This Page