Académique Documents
Professionnel Documents
Culture Documents
QuickStart
Introduction
STARTING XOJO
About the Desktop QuickStart
1. Download the installer for your operating
Welcome to Xojo, the easiest tool for creating multi-platform desktop and web
system from:
http://www.xojo.com/download.
applications. Xojo is made up of a rich set of graphical user interface objects,
a modern object-oriented language, an integrated debugger, and a multi-
2. Run the installer.
platform compiler. Together they make up the Xojo Integrated Development
3. Run Xojo. Environment or IDE.
4. In the Project Chooser, select Desktop and With the IDE, you can build your application’s interface simply by dragging
click OK.
and dropping interface objects into the application’s windows and dialogs. In
this QuickStart, you will see how easy it is. Xojo provides you with all the tools
you need to build virtually any application you can imagine.
This QuickStart is for people who are new to programming and new to Xojo. It
will give you a gentle introduction to the Xojo development environment and
lead you through the development of a working desktop application (a simple
web browser). It should take you about 15 to 20 minutes to complete this
QuickStart.
Copyright
All contents copyright 2014 by Xojo, Inc. All rights reserved. No part of this
document or the related files may be reproduced or transmitted in any form,
2
by any means (electronic, photocopying, recording, or other-
wise) without the prior written permission of the publisher.
Trademarks
Xojo is a registered trademark of Xojo, Inc.
3
Section 2
Presentation Conventions
The QuickStart uses screen snapshots taken from the Windows, • Something that you are supposed to type is quoted, such as
OS X and Linux versions of Xojo. The interface design and fea- “GoButton”.
ture set are identical on all platforms, so the differences between
• Some steps ask you to enter lines of code into the Code Edi-
platforms are cosmetic and have to do with the differences be-
tor. They appear in a shaded box:
tween the Windows, OS X, and Linux graphical user interfaces.
• Bold type is used to emphasize the first time a new term is ShowURL(SelectedURL.Text)
used and to highlight important concepts. In addition, titles of
books, such as Xojo User Guide, are italicized.
When you enter code, please observe these guidelines:
• When you are instructed to choose an item from one of the
menus, you will see something like “choose File ↠ New Pro- • Type each printed line on a separate line in the Code Editor.
ject”. This is equivalent to “choose New Project from the File Don’t try to fit two or more printed lines into the same line or
menu.” split a long line into two or more lines.
• Keyboard shortcuts consist of a sequence of keys that should • Don’t add extra spaces where no spaces are indicated in the
be pressed in the order they are listed. On Windows and printed code.
Linux, the Ctrl key is the modifier; on OS X, the ⌘ (Command) • Of course, you can copy and paste the code as well.
key is the modifier. For example, when you see the shortcut
“Ctrl+O” or “⌘-O”, it means to hold down the Control key on a Whenever you run your application, Xojo first checks your code
Windows or Linux computer and then press the “O” key or hold for spelling and syntax errors. If this checking turns up an error,
down the ⌘ key on OS X and the press the “O” key. You re- an error pane appears at the bottom of the main window for you
lease the modifier key only after you press the shortcut key. to review.
4
Section 3
Getting Started
Start Xojo 3. You should now see three fields to specify: Application
If you haven’t done so already, now is the time to start Xojo. Name, Company Name and Application Identifier.
1. Double-click the Xojo application icon to start Xojo. After it
Application Name is the name of your application. This
finishes loading, the Project Chooser window appears.
will be the filename of the actual application file that gets
created.
Figure 1.1 Project Chooser Window
Company Name is the name of your company. You may
choose to leave this blank.
Application Identifier is a unique identifier for this applica-
tion. 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 "SimpleBrowser" as the Application Name. You can
leave Company Name as it is or change it.
2. Xojo lets you build three different types of applications
4. Click OK to open the main Xojo window (called the Work-
(Desktop, Web and Console). For this QuickStart, you are
space), where you will begin designing your application.
building a desktop application, so click on Desktop.
5
Section 4
Workspace
lected), the App object and the MainMenuBar object. You use
Overview
the Navigator to navigate within your project.
Xojo opens the Workspace with the default window for your
application selected in the Navigator and displayed in the Layout Editor: The center area is the Layout Editor. You use
Layout Editor. the Layout Editor to design the user interface for the windows
in your application. It shows the window and previews how it
Figure 1.2 The Xojo Workspace looks when the application runs. In this illustration, the win-
dow is blank because you haven't yet added any user inter-
face controls from the Library.
Library: The area on the right is the Library and shows the
controls and interface elements that you can add to a window
or to the project. You design the window by dragging controls
from the Library to the window. You can also add a control to
the window by double-clicking it.
You can change how the controls display in the Library by
6
Inspector: Not shown in the above illustration is the Inspector,
which allows you to see and change the properties for the se-
lected control. This area of the Main window is shared with the
Library. You can show the Inspector by clicking the Inspector
button on the toolbar. The Inspector shows information about
the selected item in the Navigator or Editor. The contents of
the Inspector changes as you click on different items. You
change an Inspector value by entering a new value in the field
to the right of the field label.
7
Chapter 2
Simple
Browser
Application
Learn how to create a simple web browser
application.
Section 1
Overview
About the Application • Button: A Button is used to trigger an action. The user
The best way to quickly learn how to use Xojo is to create an clicks the button to load the web page at the URL into the
application. For this QuickStart, you will create a simple web HTML Viewer.
browser.
• HTML Viewer: An HTML Viewer is used to display HTML (a
A Xojo application consists of a col- web page). In this pro-
lection of objects, called classes. ject, it is what displays
Figure 2.1 The Completed Simple Web Browser Application the web site at the URL.
Nearly everything in Xojo is a class,
including your windows and its con-
The next sections walk
trols. In the SimpleBrowser project,
you through creating the
you use the default Window class to
user interface and adding
create your window and you add con-
the necessary code to
trols (user interface classes) to the
make the application
window to create the design.
work.
The application uses three controls:
9
Section 2
Designing the Window In the Library, click on the Default Button icon and drag it
You should have Xojo running and to the top-right corner of the window.
Window1 open in the Layout Editor. Figure 2.2 Choosing a 3. The final control is the HTML Viewer:
If not, please refer to the Preface, Text Field in the Library
Sections 3 and 4.
Drag the HTML Viewer
Now you are ready to start adding icon to the remaining Figure 2.3 Choose
empty area on the page HTMLViewer in the
controls to the window.
Library
(you may have to scroll
1. Starting with Text Field:
down through the con-
trols to see it).
In the Library, click on the Text
Field icon and drag it to the top- Resize this control (using the selec-
left corner of the window in the tion handles so that it fills most of
Layout Editor.
the window below the Text Field
and Button).
As you get close to the edges of
the window, you will see align- 4. The final step is to resize the Text
ment indicators that help you po- Field so that it is larger. Click on it
sition the control. to show the selection handles.
Click the center-right handle and
2. Next is the Button:
drag it to the right until the alignment guides tell you it is
close enough to the Button.
10
Your finished window layout should look like this:
11
Section 3
Properties
What is a Property?
A property is a value of a class. Changing property values al-
lows you to change the behavior of the class.
For this project, you want to change various properties for the
window and its controls. Some of the things you need to do
are:
Inspector
The Inspector is used to change the window and control
properties. It shares the same area on the right of the main
window as the Library. In order to show the Inspector, click
the Inspector button on the toolbar or press ⌘-I (Ctrl+I on
Windows and Linux).
12
Section 4
Window Properties
13
Section 5
The Text Field is where your user enters the URL they want to Click the locks so that top, left and right are locked and bot-
see in the browser. You want to change the following proper- tom is unlocked.
ties: Name and Locking
14
Section 6
Button Properties
Your users click the button to display the web page. You need 4. Lastly, you want to give your button a caption. In the Cap-
to change these properties: Name, Locking and Caption. tion field (located in the Behavior group), change the cap-
tion from “OK” to “Go”.
1. On the window, select the PushButton1 control. The In-
spector changes to show the Button properties.
15
Section 7
The last user interface change you need to make is for the Click the locks so that top, bottom, left and right are
HTML Viewer. Here you need to change these properties: locked.
Name and Locking
16
Section 8
Adding Code
17
AddressField.Text
WebViewer.LoadURL(AddressField.Text)
WebViewer.LoadURL(AddressField.Text)
18
Section 9
4. When you are finished experimenting with the Simple Browser application,
you can close the window to return to Xojo.
On OS X, choose SimpleBrowser.debug ↠ Quit to Quit the application.
19