![]() ![]() The last step to making the Add button work is to connect the Tasks array to the TaskTable control. The third and final line tells the TaskTable to reload all of its data so the user will see the new task they just entered. The second line clears the contents of the TaskField so the user can enter another task. The first line adds the Text from the TaskField and the value False as a pair to the Tasks array. To save yourself having to do a lot of extra typing, remember that when you see an ellipsis (.) in the Code Editor, pressing the Tab key on your keyboard will auto-complete the item for you.Īrrays have functions built into them, one of which is for adding items. In the Code Editor, enter the following two lines of code: When the user presses the button, the button should add a row to the Tasks array using the text the user entered in the TaskField, store to indicate the task is not yet completed, and clear the contents of the TaskField so they can enter another task. You are now in the Code Editor editing the AddButton's Pressed event. When the Add Event Handler dialog appears, the Pressed event will already be selected which is the one you want so click OK to add it. In the Layout Editor, double-click the Add button. In the Navigator, click on the AddButton to select it. ![]() Let's now make the Add button add the task to the Tasks array: If you've already done the QuickStart then you know that Events are where you put code that needs to respond to an action such as a user pressing a button. In the Inspector, enter Pair for the Type. In the Inspector, enter Tasks() as the name. A new property is added to the TaskManagerScreen. To add a new property, select Insert > Property. Let's create the array to store the tasks: To help you visualize the array, consider the list below with three tasks, the first one which is completed: The left side of the pair will store the task and the right side will store True (if the task has been completed) and False if it has not. A Pair in Xojo is two values that go together. Since you need to store both the name of the task and whether or not it's been completed, the array will be an array of Pairs. This property will be an array which is a list. You can do this by adding a property to the Screen. However, because you will want the user to be able to swipe left to mark and delete tasks, you will need to store the data elsewhere. Normally you could just add tasks as rows directly to the table. You change an Inspector value by entering a new value in the field to the right of the field label.įirst, you're going to need to create something in which to store the tasks. The contents of the Inspector changes as you click on different items. The Inspector shows information about the selected item in the Navigator or Editor. You can show the Inspector by clicking the Inspector button on the toolbar. This area of the Workspace window is shared with the Library. Inspector: Not shown in the above image is the Inspector, which allows you to see and change the properties for the selected control. If the Library is not visible, click the Library button on the toolbar to show it. You can change how the controls display in the Library by clicking the small gear icon and choosing a different setting. You can also add a control to the Screen by double-clicking it. You design the Screen by dragging controls from the Library to the Screen layout. Library: The area on the right is the Library and shows the controls and interface elements that you can add to a Screen or to the project. In this image, the Screen is blank because you haven't yet added any user interface controls from the Library. It shows the Screen and previews how it looks when the app runs on an iOS device. You use the Layout Editor to design the user interface for the Screens in your app. Layout Editor: The center area is the Layout Editor. You use the Navigator to navigate within your project. ![]() By default you can see Screen1 (which is selected), the App object, the iPhone and iPad Layout objects and items for the App Icon and optional Launch Screen. Navigator: The area on the top left shows you all the items in your project. Xojo opens the Workspace with the default View for your app selected in the Navigator and displayed in the Layout Editor. Reporting bugs and making feature requests.Building a tip calculator to compare Xojo and Swift. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |