Desktop QuickStart
Welcome to Xojo! Xojo is made up of a rich set of graphical user interface objects, the modern object-oriented Xojo programming language, an integrated debugger, and a multi-platform compiler. Together they make up the Xojo Integrated Development Environment or IDE. You'll use the IDE to build your app's interface by dragging and dropping interface objects onto the apps's windows and dialogs, then you'll add your code to each of these objects.
This QuickStart is for people who are new to Xojo. It will give you an introduction to the Xojo development environment and lead you through the development of a working desktop web browser app. It may take you up to 15 minutes to complete this QuickStart.
Getting started
Launch Xojo.
Double-click the Xojo app icon to start Xojo. After it finishes loading, the Project Chooser window appears.
You are building a Desktop app, if it's not already selected, click on Desktop.
The dialog has three fields:
Application Name: the name of your app.
Company Name: the name of your company.
Application Identifier: a unique identifier for this app. It will automatically populate using what you enter for the Application and Company Names, but you can also change it to whatever you want.
Enter your company name, your own name or leave it blank.
Enter
SimpleBrowser
as the Application Name.Click Create.
IDE workspace
The Workspace is the main window in Xojo where you design your app.
Navigator: Shows all the items in your project like windows, menus, pictures, sounds and more. Click on items in this list to edit them.
Layout Editor: Use this to create layouts for windows and dialog boxes. It's blank now because you haven't added any controls to it yet.
Library: Shows all the controls and other widgets you can drag to your layout to create your user interface.
Making a browser app
In this Desktop QuickStart, you will create a simple web browser. You use the default Window class to create your window and you add controls (user interface classes) to the window to create the design.
The app uses these controls:
Text Field: A Text Field control is used to enter text. In this project, the URL to display is typed into a Text Field at the top of the window.
Button: A Button is used to trigger an action. The user clicks the button to load the web page at the URL into the HTML Viewer.
HTML Viewer: An HTML Viewer is used to display HTML (a web page).
Building the user interface
Window1 is open in the Layout Editor. Let's start adding controls.
In the Library, click on the Text Field icon and drag it to the top-left corner of the window in the Layout Editor. As you get close to the edges of the window, you will see alignment indicators that help you position the control.
In the Library, click on the Default Button icon and drag it to the top-right corner of the window.
Drag the HTML Viewer icon to the remaining empty area on the page (you may have to scroll down through the controls to see it).
Resize the HTML Viewer control (using the selection handles so that it fills most of the window below the Text Field and Button).
Resize the Text Field by clicking it to show the selection handles. Click the center-right handle and drag it to the right until the alignment guides tell you it is close enough to the Button.
Your finished window layout should look like this:
Setting the properties
A property describes something about an object such as a window or button. Changing property values allows you to change the look or behavior of that object.
Inspector
The Inspector is used to change view and control properties. It shares the same area on the right of the Workspace as the Library.
Setting the properties for the window
Display the Inspector by clicking the Inspector button on the toolbar or press ⌘-I if you're on macOS or Ctrl+I on Windows and Linux.
You need to change the Name and Title properties:
In the Layout Editor, click on the title bar of the window to select it. The Inspector now shows the properties for the window.
In the Name field (located in the ID group), change the name from
Window1
toBrowserWindow
. Press RETURN to see the name change in the Navigator.
In the Title field (located in the Frame group), change the name from
Untitled
toWeb Browser
.
Setting the properties for the text field
The Text Field is where your user enters the URL they want to see in the browser.
On the window, select the TextField control. The Inspector changes to show the Text Field properties.
In the Name field, change the name from
TextField1
toAddressField
.
Now make changes to the locking so that the Text Field gets larger or smaller as the window resizes. Click the locks so that top, left and right are locked and bottom is unlocked.
Setting the properties for the button
Your users click the button to display the web page.
On the window, select the Button1 control. The Inspector changes to show the Button properties.
In the Name field, change the name from
Button1
toGoButton
.
Now you need to make changes to the locking so that the Button stays attached to the right side of the window when it is resized. Click the locks so that top and right are locked and left and bottom are unlocked.
Give your button a caption. In the Caption field (located in the Appearance group), change the caption from
OK
toGo
.
Setting the properties for the HTML viewer
The last user interface change you need to make is for the HTML Viewer.
On the window, select the HTMLViewer1 control. The Inspector changes to show the HTML Viewer properties.
In the Name field, change the name from
HTMLViewer1
toWebViewer
.
Finally, you need to make changes to the locking so that the HTML Viewer continues to fill the window when it is resized. Click the locks so that top, bottom, left and right are locked.
Adding code
Your app is almost complete. Now it is time to add the code that will tell the HTML Viewer which web page to display.
On the window, double-click the Button control, that you named Go. The Add Event Handler window appears. When a user presses a Button, your app runs the code in its Pressed event handler.
Make sure Pressed is selected in the Event Handler list and click OK.
Notice the Navigator updates to show the Pressed event underneath the GoButton control and the Code Editor displays.
Go ahead and add this code to the Code Editor. If you don't see the cursor flashing in the Code Editor (the text editing area in the middle of the window), click in that area below the Pressed() event name and then type this code: (It's good practice to type it rather than copy and pasting it)
WebViewer.LoadURL(AddressField.Text)
What does this code do? The URL that a user will type into the Text Field is stored in its Text property, AddressField.Text. Then we want our code to display the web page in the WebViewer, which is done by calling the LoadURL method and sending it to the URL that the user typed.
That's it! Your first app is complete.
Saving your project
You should save your work periodically and always before running your project. To do so:
Save the project by choosing File > Save.
Click Save.
Running the app
Now you can test your finished app:
Click the Run button in the toolbar to run your project. The app opens in its own window.
Type a URL of your choice, remembering to start with
https://
.Click the OK button. Your webpage appears.
Try resizing the window to make it bigger so you can see more of the page. Notice the controls resize or move when you do this.
Try another URL. This time, enter
https://showcase.xojo.com
.You will see the web page with the Xojo Showcase.
When you are finished experimenting with the Simple Browser app, you can close the window to return to Xojo. On macOS, choose SimpleBrowser.debug > Quit to Quit the app.
Next steps
This QuickStart has introduced you to Xojo and you've learned how to make your first app by designing a window, adding controls and writing code. A good next step is the Desktop Tutorial. Then explore the Topics and API sections of the documentation to continue learning how to create great apps using Xojo.