How hard would this be to achieve?

Veljo

Mac Enthusiast
I've done a little bit of programming here and there, but nothing too major. I'm looking at creating a (if possible) Universal app that does one simple thing — display a window which loads a set URL (which will have a Flash animation on it).

How hard would this be to create, and what applications do you recommend?

I tried using REALbasic and I had the program working, but it was generally unstable and terribly easy to crash.

What about the tools bundled with Tiger? If those are recommended, what do you suggest for tutorials/online help?
 
You might want to look here and here.

I guess this could also be done with a few lines of AppleScript, loading the page in Safari (with a specified size and no controls or bars)
 
I've done something, but could someone tell me how to make a web box load a specified URL on its own automatically without an address bar?
 
You mean in Safari? There's no (easy) way to do that remotely. You can do it from within your web site with JavaScript, but I don't know of any way to send that kind of data through an URL request. There probably is some way (there almost always is!), but I imagine it would be too complicated to bother with.

As for how to make a univeral binary with an embedded web browser, Xcode is the way to go. See MacDevCenter's Build Your Own Browser tutorial.
 
gargwag.jpg


As can be seen above I've managed to get the WebKit working inside the window, and it resizes nicely with the window so that's good.

Like I said before, I'm not sure how to make it automatically load a set URL by itself. I could give the text box a default value and hide it, but it won't do anything without the Return key. Either way, I hope someone has the solution for me.

This is a pretty small and basic app, so I figured it wouldn't be too hard to make. The only other thing I wanted to chance was the About dialog.

Thanks for your help everyone.
 
... don't you have to get the url out of the text box and call some method when the user hits the return key? Can't you just hardcode the url and send off the message?

Maybe it's easier said than done... but there isn't some magical event that gets triggered when a user hits return, there has to be code setup to do it... and you certainly don't need a text box because you are just getting the string value out of the box...

[edit]
OK I shouldn't have been so sarcastic, after looking at that link I noticed that there is no code involved in that example. You should, however, be able to create a controller class with one outlet (the WebView) and create a method (is it awakeFromNib?) that runs when the UI is loaded. In there call a method (there has to be one) that sets the url of the WebView and tell it to load. If I had a Mac with me and I didnt' have exams tomorrow I'd take a closer look for ya. But alas... Finance calls... barf!
[/edit]
 
Yes, you'll need to actually write some code (aiieeee! ;)). The good news is that you'll only need about three lines (or just one, if you don't value readability). The bad news is that setting up the place to even PUT this code is far from intuitive.

HateEternal has it. You want to do this:

A) Create a custom class.
B) Hook up the web view to it.
C) Put your code in it.

Sounds easy enough, but figuring out how to do this is the hardest part of learning Cocoa. To do this, open your Xcode project, open your nib from there, and then follow these way-too-many steps:

1. Click on the Classes tab (in Interface Builder).
2. Select NSObject (scroll to the left if necessary).
3. Create a subclass, in the Classes menu. Name it whatever you want. I'll assume you leave it as "MyObject".
4. In the Attributes section of the Inspector window (command-1), select the outlets tab, and create a new outlet. Again, name it whatever you want. I'll assume you leave it as "myOutlet".
5. Under the Classes menu, select "Create Files for MyObject". In the dialog that appears, be sure your Xcode target is in the list. If it's not, open your project in Xcode in try again.
6. Under the Classes menu, Instantiate MyObject.
7. Hold down the Control key and drag from the new MyObject icon (in the Instances tab) to the WebView you made in your window.
7. Select "myOutlet" from the inspector window and click Connect.
8. Save and go back to Xcode.
9. In Xcode, open MyObject.m and enter this after the @implementation line:
Code:
- (void)awakeFromNib {
	NSURL *url = [NSURL URLWithString:@"http://www.macosx.com"];
	NSURLRequest *request = [NSURLRequest requestWithURL:url];
	[[myOutlet mainFrame] loadRequest:request];
}
Then save and run. It should load macosx.com immediately upon launch.
 
Back
Top