Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 8, 2013, 11:49 AM   #1
furycd001
macrumors member
 
Join Date: Mar 2011
Location: Belfast
Linking a button or image to a url...

HI everyone

How would I go about linking a button or an image to a url in xcode / interface builder :?

Basically what I would like to do is have a button or image within an app on my mac desktop, that whenever clicked it will take me to a specified hardcoded url. All the tutorials I have found online refer to creating IOS based apps. Any help would be appreciated & sorry is this is a dead silly question...
__________________
[ Furycd001 ]

[ 13" MacBook, 2 GHz, 2 GB RAM, 1 TB HD, Ver 10.9.2 | Ipod classic | iPod touch | Iphone 4, 16 GB, Black ]
furycd001 is offline   0 Reply With Quote
Old May 11, 2013, 02:31 AM   #2
larswik
macrumors 65816
 
Join Date: Sep 2006
What have you tried so far that didn't work?
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old May 11, 2013, 10:29 AM   #3
furycd001
Thread Starter
macrumors member
 
Join Date: Mar 2011
Location: Belfast
Quote:
Originally Posted by larswik View Post
What have you tried so far that didn't work?
I haven't really tried anything because I am unsure of what to connect the button to. I have though tried following some tutorials though they were iphone based, so I new they wouldn't work.

Someone on a programming irc channel told me to try the following...
Quote:
Try creating an action handler in the script object, then connecting the button to the newly created handler. The code in the handler will check to see what button was pressed, then it will take the appropriate action.
If this would work how would I go about creating an action handler ??

Sorry but I am relatively new to programming & still learning. Your help will be much appreciated.
__________________
[ Furycd001 ]

[ 13" MacBook, 2 GHz, 2 GB RAM, 1 TB HD, Ver 10.9.2 | Ipod classic | iPod touch | Iphone 4, 16 GB, Black ]
furycd001 is offline   0 Reply With Quote
Old May 11, 2013, 06:51 PM   #4
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
iOS and OS X are pretty darn similar... I would suspect that you can follow an iOS tutorial for this task to the t for an OS X app and end up with the same app (but for OS X, of course.)

Edit: Well, the code for opening the URL might change... Try just hooking up a button to an IBAction that NSLogs the URL first. Then you can look into opening a URL on OS X.
ArtOfWarfare is offline   0 Reply With Quote
Old May 12, 2013, 01:30 AM   #5
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Less lost in L.A.
Quote:
Originally Posted by furycd001 View Post
Basically what I would like to do is have a button or image within an app on my mac desktop, that whenever clicked it will take me to a specified hardcoded url.
I'm confused. Which is it? You want an icon on your desktop that you can double click to go to a specific URL, or you want a button within an app that takes you to a URL? Those are two different things.

If the first, simply drag the URL from Safari to the desktop. Automator maybe another simple option for this tactic.

If the second, look at using the openURL: method of the NSWorkspace.
Code:
   NSURL * mtDotCom = [NSURL URLWithString: @"http://www.morphedthoughts.com"];
   [[NSWorkspace sharedWorkspace] openURL: mtDotCom];
__________________
My App: CameraTime - Time lapse photography for novice and advanced users.
xStep is offline   0 Reply With Quote
Old May 12, 2013, 03:51 AM   #6
furycd001
Thread Starter
macrumors member
 
Join Date: Mar 2011
Location: Belfast
Thanks for the replies everyone.

No I don't want an icon on my desktop, I was just either going to use a button or an image for the link in my app (i've decided on button). Thank you for the snippet of code, I will give that a whirl & see what happens. I will also try IBAction too...
__________________
[ Furycd001 ]

[ 13" MacBook, 2 GHz, 2 GB RAM, 1 TB HD, Ver 10.9.2 | Ipod classic | iPod touch | Iphone 4, 16 GB, Black ]
furycd001 is offline   0 Reply With Quote
Old May 12, 2013, 12:01 PM   #7
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Less lost in L.A.
That snipet of code will work well within an action method. That is how I tested it.
xStep is offline   0 Reply With Quote
Old May 17, 2013, 05:52 PM   #8
furycd001
Thread Starter
macrumors member
 
Join Date: Mar 2011
Location: Belfast
Thank you for your help, I got everything working :-)
__________________
[ Furycd001 ]

[ 13" MacBook, 2 GHz, 2 GB RAM, 1 TB HD, Ver 10.9.2 | Ipod classic | iPod touch | Iphone 4, 16 GB, Black ]
furycd001 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Set image Button Toggle 204 iPhone/iPad Programming 3 Jun 7, 2013 08:15 AM
Using DropBox image url-link? BDM STUDIOS NL Site and Forum Feedback 21 May 29, 2013 06:31 PM
When I google image search a picture how do I get the direct URL? dopaminedude iPhone 1 Apr 8, 2013 12:10 AM
Resolved: button suddenly does not look like its image straber iPhone/iPad Programming 2 Apr 6, 2013 05:13 PM
URL Linking To Certain Page? AFPoster Web Design and Development 7 Dec 7, 2012 12:09 AM

Forum Jump

All times are GMT -5. The time now is 12:05 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC