- Lesson 2 - Application development
- Overview
- Displaying the list of products
- Creating the window
- Window test
- Creating the form window
- Creating the window
- Creating the controls
- Improving the UI
- Displaying the data of a given record in the product form
- Opening the form from the list of products
- Editing a product
- Adding a validation option to the Action Bar
- Refreshing the list of products
- Window test
- Adding a product
- Principle
- Opening the product form from the Action Bar
- Adding a product
- Window test
- Using the camera and displaying an image
- Overview
- Creating the button for taking photos
- Control style
- Taking photos
- Creating a button to select a photo from the device
- Product bar code
- Overview
- Implementation
- Defining anchors in the Product form
- Using the Map control
- Creating the window
- Creating the Map control
- Displaying stores on the Map control
- WLanguage code associated with the window
- Using a Multiline Zone control
- Creating the window
- Creating the Multiline Zone control
- Modifying the Multiline Zone control
- Programming the menu
- Application test
- To sum up
Tutorial - Developing an Android and iOS application
Lesson 2 - Application development We will cover the following topics: - Creating a window containing a looper.
- Discover specific fields: RepeatString Looper control, Multiline Zone control, Map control, etc.
- Manipulating the database.
- Features specific to the device used (GPS, Camera, etc.).
1h In this lesson, you will create several windows: - a window with the list of products. When a product is clicked, a second window will open, allowing you to edit the product. It will also be possible to create a new product.
- a window to interact with maps.
- a window with a menu.
Warning
This lesson is based on the WM Product Management example used in Lesson 1. To follow this lesson, you must have completed the steps in Lesson 1.
Displaying the list of products We will create a window to list different products. These products will be displayed in a "Looper" control. Creating the window To create a new window: - Click in the quick access buttons (or press Ctrl + N).
- In the "New" window, click "Window", then "Window".
- In the wizard, select the "Standard" tab.
- In the "Phone" area, choose "Looper" and validate.
Reminder: The lessons in this tutorial are based on an Android configuration. If you are using an iOS configuration, you might find iOS-specific options. - The window creation wizard opens.
- Since our project contains multiple platforms (iOS and Android), the wizard prompts you to select the platform to be used to create the window. We recommend that you select the platform with the lowest resolution (in this case, "Generic iPhone").
Proceed to the next step of the wizard.
If your project contains both platforms (Android and iOS), choosing "generic iPhone" will automatically generate the window for this platform. "iOS" automatically becomes the current platform of your project. - The wizard prompts you to choose the data source associated with the window. In our case, it will be the "Product" data file:
- The "Data files" option is selected by default.
- Select the Product data file.
- Go to the next step.
- Select the style of the RepeatString Looper control: "Image + Title + Label below". This template provides an interface containing the product image, name and description.
- Go to the next step.
- The wizard automatically shows the data file items that correspond to the different controls of the generated looper.
- Keep the default items and go to the next step.
- Keep the suggested sort on the "ProductID" item. Go to the next step.
- The wizard proposes several options for generating the Looper window:
- Generate a creation button in the Action Bar If this option is selected, the wizard will generate a window for data entry.
- Enable the deletion by row swipe If this option is selected, the user can delete an item from the RepeatString field by simply scanning the corresponding line.
- Row selection code If the "Generate the opening code of the form in read-only mode" option (or the "Generate the opening code of the form in edit mode" option) is selected, the wizard proposes to generate a form window for display or input.
- In our example, keep the default options. Go to the next step.
- Define a title and a name for the window. Type the window title: "List of products". The window name is automatically filled.
- Finish the wizard. The window is automatically created, displayed in the editor and saved. If your project uses the iOS and Android configurations, the window appears in the iOS configuration.
The data is already displayed in the control, even in the editor. This is the "Live data " concept: the contents of data files present on the development workstation are used in windows or reports manipulated under the editor.. This feature is very useful to define the size of the controls in a window, for example.
It can also be used to adapt the size of the controls to their content.
Our project uses two project configurations: let's look at the same window for the Android configuration: - Expand "Configurations (iOS application)" at the top of the "Project explorer" pane.
- Double-click the "Android application" configuration.
- The Android configuration is automatically selected and the corresponding window appears.
Window test We will run a first test in the Android simulator to see the result: - Click in the quick access buttons (or press F9).
- Close the simulator to go back to the window editor.
When a project is associated with multiple platforms, the window is tested in the current platform. The simulator adapts to reflect the current platform. We will create a new window to display the product form. Then, this window will be opened from the list of products to display the details of the selected product. Creating the window To create the form window: - Create a new blank window.
- Click in the quick access buttons.
- When the new element window appears, click "Window" then "Window".
- In the wizard, select the "Standard" tab, choose "Blank" and validate.
- The save window appears. Specify the window title: "Product form". Its name is automatically proposed: "WIN_Product_form". Validate.
- The window is added to the project, for all configurations.
If multiple platforms are defined in the project, the save window associates the new element to all platforms. To associate the element to a single platform, simply expand "Configurations" in the save window and choose the desired platform. Creating the controls Our window must contain different controls with the product details. These controls will be bound to the items of the Product data file. To create the different controls, we will use the items of the Product data file directly: - Display the "Analysis" pane if necessary: under the "Home" pane, in the "Environment" group, pull down "Panes" and select "Panes" then "Analysis". The different data files of the "WM Product Management" analysis appear in the pane.
- Select the items of the "Product" data file displayed in the pane (except for the "ProductID" item).
- Drag the items and drop them onto the window (for example, on the upper-left area).
The controls are automatically created and selected. We need to make a few changes to improve the UI. Improving the UI We are going to reorganize and resize the controls. Move all the controls to the bottom of the window. - If necessary, select all the controls (Ctrl + A).
Note: All fields are already selected during creation. - Move all the controls down.
We will now create our UI step by step. Step 1 - Image Click the Image control to select it. Move the control to the top center of the window.
Alignment guides appear when moving the Image control. These guides help you place controls relative to the window or to other controls. Step 2 - CaptionHorizontally enlarge the control that contains the caption so that it fits the window. Place the control below the Image control. Step 3 - Description Move the "Desc." control below the Caption control. "Desc." is a multiline control that contains the product description. Enlarge the control vertically to display at least three lines of text.
Align the Caption and Description controls: - Select both controls (the caption must be selected first).
- Go to the alignment options ("Alignment" tab of the WINDEV Mobile ribbon).
- We will align the outside and inside borders of the controls. Click "Justify (Ins. and Out.)".
Step 4 - Price and Reference Move the Price control below "Desc.". Reduce the control so that it occupies half of the window width. Place the Reference control next to Price and reduce it horizontally so that it fits the window. Use the alignment guides to align the right side of the Reference control with the Caption and Description controls.
Tip: To keep the input field to a manageable size, you can use the red inner handle of the input field to reduce the space between the label and the input field. Step 5 - Bar codePlace the Bar code control below the Price control. Step 4 - Quantity and Reorder Place the Quantity and Reorder controls side by side as you did for the Price and Reference controls. You will get the following result.
Save the window. Tab order in the windowWe changed the order of the controls in the window. This order defines how focus moves from one control to another. For more details, see Tab order in a window, a page, etc. Let's quickly test the window: - Test the window (click in the quick access buttons).
- The window is displayed with empty controls.
- Close the simulator.
The controls are empty because no record has been selected in the data file. Therefore, no data is displayed. We will see how to display the data of a given record in the window, and how to open this window from the list of products. Displaying the data of a given record in the product form You can programmatically display the data from a given data file record. To display the product data: - Open the WLanguage events of the WIN_Product_form window:
- In the open document tabs, right-click the tab of the current window.
- In the context menu that appears, select "Element code".
- The code editor appears.
- Enter the following WLanguage code in the "End of initialization of WIN_Product_form" event:
<Data file>.ToWindow gets the data from the current record in the data file and displays it in the window controls. In our case, the current record is the record selected in the Looper control of "WIN_List_of_products". This Looper control is linked to the Product data file. - Close the code window.
- Save the window.
To test this code, a record must be selected. To do so, we will write the code to open the product form from the list of products. Opening the form from the list of products To open the product form of the selected product, perform the following actions: - Go to the "Product List" window: click on the "FEN_Product_List" button in the open document tabs (under the WINDEV Mobile menu ribbon):
- Select the Looper control.
Warning: make sure you select the RepeatString field and not one of the fields in the RepeatString field. - Right-click to open the context menu of the Looper control and select "Code".
- In the code editor, write the following WLanguage code in the "Select a row in LOOP_Product" event:
WIN_Product_form.OpenMobileWindow()
Enter this code on the keyboard and let the code-entry assistance guide you: as soon as you type the first letters of the window name, a drop-down list opens, proposing the names of the various project elements beginning with these letters. Select the name of the desired window. Similarly, the different functions and properties that can be used in the window appear when you insert a '.' (dot) after the name of the window. - Save changes by clicking in the quick access buttons.
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
Let's test the "WIN_List_of_products" window again in the simulator: - Click in the quick access buttons.
- In the list of products, click one of the products.
- The detailed product window is displayed.
Close the simulator. We will now modify our two windows and add an option to confirm the changes made to a product. When creating the form window, an Action Bar was automatically created. This Action Bar contains a button on the left to cancel the current input and go back to the previous window. In our case, this button will be used to go back to the list of products.
This behavior corresponds to what we want: no modification is required. We only need to add a validation button to the Action Bar of the "WIN_Product_form" window to apply changes. Adding a validation option to the Action Bar To add a validation option to the Action Bar of "WIN_Product_form": - Open the "WIN_Product_form" window in the editor (click on it in the open document tabs).
- Select the Action Bar (at the top of the window).
- Open the Action Bar description window (select "Description" in the context menu).
The Action Bar description window adapts to the platforms used in the project. The Action Bar of an Android application is different from the Action Bar of an iOS application. Our project uses both Android and iOS configurations the window displays a preview of the Action Bar for both platforms. You can click the numbers to access the options you want to configure. - Click number 2 (any number 2 in the window). A new UI allows you to enter an option in the Action Bar.
- Click "+" (below the "Top right" area) to add an option. A new option is created at the top right.
- Modify the characteristics of this option:
- In the "Option caption" area, type "Done".
At runtime, the option caption appears in the Action Bar: - If no image is associated with the option.
- If the option is moved to the bottom menu.
- In the "Preset image" area, expand the list and select "Done".
- Confirm changes and close the description window.
To go back to the Action Bar description, simply click .
- The WLanguage code of this option will be used to save the changes in the "WIN_Product_form" window. To write this code:
- Select the Action Bar control.
- Click "OK".
- A drop-down menu with the "Done" option appears.
This drop-down menu is only visible in edit mode to enter the WLanguage code associated with the option. This drop-down menu will not be displayed at runtime. - Right-click the option.
- Select "Code" in the context menu that appears.
- Write the following WLanguage code in the "Select a menu" event:
Product.FromWindow()
Product.Save()
Close()
Let's take a look at these lines of code:
- Save changes by clicking in the quick access buttons.
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
Refreshing the list of products When the product form is closed, the content of the list of products in the "WIN_List_of_products" window must be refreshed to take into account the changes made in the form. To do so, use the "Close a child window" of "WIN_List_of_products" event. - Click "WIN_List_of_products" in the open document tabs:
- Right-click the window background and select "Code" in the context menu. The following WLanguage code is automatically displayed in the "Close a child window" event:
LooperDisplay(LOOP_Product,taCurrentSelection)
The generated code does not use prefix syntax but WLanguage "standard" syntax. In prefix syntax, this code is as follows: LOOP_Product.Display(taCurrentSelection)
- Let's take a look at this WLanguage code:
- The "Close a child window" event is run when the child window of the current window is closed. In our case, it is run when the "WIN_Product_form" window is closed.
- <Looper>.Display (or LooperDisplay) updates the Looper control data in the "WIN_List_of_products" window. The taCurrentSelection constant updates the data according to the selection bar.
This WLanguage code was automatically generated when the wizard created the window.
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
Window test Test the "WIN_List_of_products" window in the simulator (click in the quick access buttons). - In the product list, click on one of the products with the mouse: for example, the product "Polo Hibbicus, Blue".
- The product detail window appears. Change the name to "Polo Hibiscus, Light blue" and click "OK".
- When going back to the list of products, you will notice that the name of this article was updated.
Close the simulator. The WINDEV Mobile editor is displayed. Principle The principle for creating a product is as follows: - In the list of products, we will add an option in the window Action Bar to open the "Product form" window.
- Then, we will edit the WLanguage code of the "Product form" window to add data to the Product data file.
Opening the product form from the Action Bar To add an option to the Action Bar: - If necessary, display the "FEN_Liste_des_produits" window under the editor: click on the corresponding button in the open document tabs.
- Select the Action Bar (at the top of the window).
- Display the Action Bar description window: right-click and select "Description" from the context menu.
- Click number 2 (any number 2 in the window). The interface for entering a toolbar option appears.
- Click "+" (below the "Top right" area) to add an option. A new option is created at the top right. Modify the characteristics of this option:
- In the "Option caption" area, type "New product".
- In the "Preset image" area, expand the list and select "Add".
- Confirm changes and close the description window.
- The WLanguage code of this option will open the "Product form" window and reset its controls. To enter this WLanguage code:
- Select the Action Bar control.
- Click the "+" button.
- A drop-down menu with the "New product" option is displayed.
- Right-click the option.
- Select "Code" in the context menu that appears.
- Write the following WLanguage code in the "Select a menu" event:
Product.Reset()
WIN_Product_form.OpenMobileWindow()
<Data file>.Reset resets the item variables in the "Product" data file to the default values to handle the new record.
- Save changes by clicking in the quick access buttons.
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
Adding a product Let's now check how to add records in the product form window. - Select the "WIN_Product_form" tab to open the window in the editor.
- Open the code of the validation option in the Action Bar:
- Select the Action Bar.
- Click "OK".
- A drop-down menu with the "Done" option appears.
- Right-click "Done" and select "Code" in the context menu.
- The WLanguage code of the "Click" event does not change:
Product.FromWindow()
Product.Save()
Close()
Let's look at this code again:
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
Window test Open "WIN_List_of_products" in the window editor and test it in the simulator ( in the quick access buttons). - Click "+" in the Action Bar.
- Enter a new product.
- Validate. The new product appears in the list of products.
- Close the simulator.
Our project uses several platforms: we recommend that you create a GO for each platform. You will notice the application looks and behaves differently on each platform in the simulator. Using the camera and displaying an image Overview We will manage the product image using the device camera. To do so, we are going to: - create a Button control to launch the camera. The photo will be stored as an image in memory and displayed in the Image control of the product.
- create a Button control to select a photo from the mobile device's album.
Warning
To test this feature, the test must be run on the mobile device, and not in the simulator. This feature requires hardware components that are not available in the simulator. When a test is run on a mobile device, the application generation wizard opens automatically. For more details on generating a mobile application, see the following tutorials:
Creating the button for taking photos To create the Button control to be used to take photos: - Open the "WIN_Product_form" window.
- Position the Image control on the left of the window.
- Align it with the Static Text control using the alignment rulers.
- Add a Button control in the window:
- In the "Creation" pane, in the "Usual controls" group, click on : the shape of the field appears under the mouse.
- Then click on the top right of the Image control to create the Button control.
We will modify the Button control to associate it with an image representing a camera: - Right-click the control to open its context menu.
- Select "Description". The control description window appears.
- On the "General" tab, click to the right of "Image". in the context menu, select the "Catalog" option.
- The image catalog of WINDEV Mobile opens. This catalog contains hundreds of images in different fields, formats and sizes.
- Enter "photo" in the search box at the top and validate. Several images are displayed:
- Double-click the image to select it.
- In the window that appears, you can select the image size, color, orientation, format and name.
- Keep all default options and name the image "Camera".
- Validate the window.
- The path of the image is displayed in the Button control description.
- Give the field a name: "BTN_Appareil_Photo".
- Clear the control caption.
- Validate the description window.
- In the editor, reduce the control size.
Control style The project uses the "Material 3" skin template. This Button control uses the default style (purple background). We have already modified this style by adding the image. As we don't need the purple background for this button, we will change the style associated with the control: - If necessary, select the previously created Button control.
- Open the context menu and select "Choose a style".
- The window that appears shows all the styles that can be used for the Button controls in the "Material 3" skin template.
- Click the search bar and enter "BTN_Blank". This name corresponds to a style without background color. This is the style we are going to use.
- Validate the style selection window.
- The chosen style is automatically applied to the Button control. The image associated with the Button control is preserved.
Taking photos We will now enter the WLanguage code to take a photo and display it in the Image control of the product form.
To take photos: - Right-click the Button control and select "Code" in the context menu.
- Write the following WLanguage code in the "Click" event:
ProductImage is string
ProductImage = VideoStartApp(viPictureCapture)
IF ProductImage <> "" THEN
IMG_Photo = ProductImage
END
In this WLanguage code, VideoStartApp is used to launch the native camera application on the device to record videos or take photos. - Save changes by clicking in the quick access buttons.
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
Creating a button to select a photo from the device We will add a Button control to select a photo from the device album and associate it with the product.
To create the Button control, we will copy and paste the Button control we created previously: - Select the "BTN_Camera" control.
- Use the Ctrl + C key combination: the Button field is copied to the clipboard.
- Use the Ctrl + V key combination: the mouse cursor changes and the field shadow appears below the cursor.
- Click in the window next to the "BTN_Appareil_Photo" field: the new Button field is automatically created.
- Open the control description window (double-click the control):
- Give the field a name: "BTN_Album_Photo".
- Select an image in the image catalog.
Note: Remember to change the default image name.
- Confirm changes and close the description window.
Note: As this Button field corresponds to a "Copy - Paste" of the Photo button field, the style characteristics are automatically the same. There is no need to change them! The WLanguage code of this Button control opens the device's photo album and selects an image to display it in the Image control of the product form. - Right-click the button and select "Code" in the context menu.
- Replace the WLanguage code of the "Click" event with the following WLanguage code:
ProductImage is string
ProductImage = AlbumPicker(albumImage)
IF ProductImage <> "" THEN
IMG_Photo = ProductImage
END
In this WLanguage code, AlbumPicker retrieves the selected photo from the photo album. - Save changes by clicking in the quick access buttons.
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
Overview The "Product" data file contains a "Bar_Code" item. This item is used to store the value of a bar code. Some devices (especially the ones equipped with a camera) can scan a bar code to retrieve its value. The bar code will be scanned with the camera of the device and managed by a specific WLanguage function.
Warning
To test this feature, the test must be run on the mobile device, and not in the simulator. This feature requires hardware components that are not available in the simulator. When a test is run on a mobile device, the application generation wizard opens automatically. For more details on generating a mobile application, see the following tutorials:
Implementation First, we will create a Button control. | A vous de jouer: As we have already created several buttons in this lesson, here are just a few indications: - Create the control next to the "Bar code" control (resize the Edit control if necessary).
- Name the button "BTN_Bar_Code".
- Leave the caption blank.
- Select a bar code image from the image catalog.
|
Reduce the control size if necessary. Let's change the style of this control, as we did with the camera button. We will copy the same style we used for the previous buttons: - Select the camera button.
- On the "Style" tab, in the "Style and skin template" group, click "Copy style".
- Then click the Button control you previously created. The style is automatically applied.
Let's write the WLanguage code of this control. This code will be used to scan the bar code. - Double-click the control and select "Code" in the context menu.
- Write the following WLanguage code in the "Click" event:
bc is BarCode
bc = BCCapture()
IF bc.Content <> "" THEN
EDT_Bar_code = bc.Content
END
In this WLanguage code, BCCapture decodes the information stored in a bar code using the camera of the device. - Save changes by clicking in the quick access buttons.
- Close the code window (click "X" in the code editor tab).
Defining anchors in the Product form All controls have been positioned in the Product form. The vertical and horizontal resolution may differ according to the devices. Anchors are used to adapt the size of the controls to the resolution and avoid "empty" spaces in the window (especially at the bottom right). If the target device is specified when the project is created, the window size will be set to fit the target device. In this case, no anchoring is required. If the target device is not specified or multiple devices are used, the smallest common resolution must be chosen when creating the project. Anchors must be set in this case.
Let's set the anchors of the different controls in the window: - Select the following controls (click each control while holding down the Ctrl key):
- the Image control that displays the product image,
- the Button control used to take photos,
- the Button control for selecting a photo from the album.
- Right-click to open the context menu of the selection and select "Anchor".
- Select "Horizontally centered" ().
- Validate.
To set the anchors of the Edit controls: - Select the following Edit controls (click each control while holding down the Ctrl key):
- Caption
- Description
- Bar code
- Reorder date
- Right-click to open the context menu of the selection and select "Anchor".
- Select "Width" ().
- Validate.
Repeat this action for the Reference control and the Button control used to manage bar codes. In this case, select "Right" ( ). All anchors have been defined in the window. The red arrows indicating the orientation of anchors are displayed:
We will see the Map control and the GPS WLanguage functions. Our database contains a "Store" data file. This data file contains the addresses of the stores that will be located on a map using the mapping functions. Creating the window We will create a new window and add a Map control.
| A vous de jouer: As we have already created a window in this lesson, here are just a few indications: - Create a blank window.
- Enter "Map of stores" for the window title (the name "WIN_Map_of_stores" is automatically filled).
|
Creating the Map control To create the Map control: - On the "Creation" tab, in the "Graphic controls" group, click "Map". The control shape appears under the mouse.
- Click inside the window to create the control. The Map control appears in the window editor.
- Open the "Map" control description window (double-click the control for example).
- In the control description window, name the control "MAP_STORE" and validate.
- Save changes by clicking in the quick access buttons.
Displaying stores on the Map control We will write the code to display all the stores from the "Store" data file on a map. To do so, we will loop through the "Store" data file with a FOR EACH loop. Then, we will use Marker variables. Marker variables allow you to define the markers that will be displayed on a map. A marker contains different information. We will use the following information: <Map>.AddMarker adds a marker in the Map control. Then, simply adjust the zoom level to view all the markers in the Map control. If the zoom is not properly adjusted, some markers may not be visible or may overlap on the control. WLanguage code associated with the window We will write the WLanguage code used to display the stores directly in the initialization event of the window that contains the Map control. To write the WLanguage code to display the stores: - Select the window tab in the open document tabs and click "Element code" in the context menu. The different WLanguage events associated with the window are displayed.
- Write the following WLanguage code in the "Global declarations of..." event.
StoreMarker is Marker
FOR EACH Store
StoreMarker.Position.Latitude = Store.Latitude
StoreMarker.Position.Longitude = Store.Longitude
StoreMarker.Name = Store.Name
MAP_STORE.AddMarker(StoreMarker)
END
MAP_STORE.Zoom = zoomAdaptSize
- Save changes by clicking in the quick access buttons.
- Close the code window.
Test the "WIN_Map_of_stores" window in the simulator (click in the quick access buttons).
Warning
During the test, the map may show a loading error message. The Map control is subject to specific terms and conditions. These conditions must be met for the Map control to be displayed correctly on the device. For more details, see Conditions for using the Map control.
Close the simulator. Using a Multiline Zone control The "Multiline Zone" control is usually used on mobile platforms. This control is used to group multiple controls: - options of a category,
- information about a contact, etc.
This control can contain at the same time: - rows defined in edit mode (static rows),
- rows defined at runtime, through programming (dynamic rows).
We will use a Multiline Zone control to create the main menu of the application. We will create a new window and insert a Multiline Zone control. The window that will be created is as follows: Creating the window We will create a window and add a Multiline Zone control.
| A vous de jouer: As we have already created a window in this lesson, here are just a few indications: - Create a blank window.
- Enter "Menu" for the window title (the name "WIN_Menu" is automatically filled).
|
Creating the Multiline Zone control To create the Multiline Zone control: - On the "Creation" tab, in the "Data" group, click "Multiline Zone". The control shape appears under the mouse.
- Click inside the window to create the control.
- Open the control description window (double-click the control, for example).
- In the description window, specify the control name ("MZ_MENU") and validate.
The Multiline Zone control contains an empty row. We will add as many rows as the number of options in our menu. Our menu will include 3 options: - List of products.
- Map of stores.
- Exit application.
Modifying the Multiline Zone control To modify the Multiline Zone control: - Open the control description window (double-click the control, for example).
- Click "New row". A window is opened: this window contains all the preset line templates.
- Select "Simple row with icon" and validate. Repeat this operation twice.
Now, the Multiline Zone control contains:- a "blank" row,
- 3 "simple rows with icon".
- We will remove the blank row in our example:
- Select the blank row (the first row).
- Then click "Delete".
- Confirm changes and close the description window. Your menu is created.
Each row includes an Image control, a Static Text control and an arrow image. We will change the image and text of each row to represent the actions in the menu.
Change 1st line: access product list To change the image in the first row of the Multiline Zone control: - Click the Image control in the first row.
- Open the image description window (double-click the control).
- In the description window:
- Give a name to the image ("IMG_ListOfProducts" for example).
- Click . Select "Catalog" in the context menu that appears to select an image representing the action.
- In the image catalog window, type "List" in the search box and press Enter.
- Double-click the image you want to select.
- In the image configuration window, select a size (80 for example, W (Width) = 80 and H (Height) = 80), give a name to the image (e.g. "ListOfProducts") and validate.
The image used in a Multiline Zone control is in "Homothetic extended centered" mode by default. The image will be automatically "resized" to the proper dimensions.
- Validate the description window.
To change the text in the first row of the Multiline Zone control: - Click the Static Text control in the first row.
- Open the description window (double-click the control).
- In the "General" tab of the description window:
- Give a name to the control ("STC_ListOfProducts" for example).
- Change the caption ("List of products" for example).
- Validate the description window.
Change 2nd line: access the store map To change the image in the second row of the Multiline Zone control: - Click the Image control in the second row.
- Open the image description window (double-click the control).
- In the description window:
- Give a name to the image ("IMG_MapOfStores", for example).
- Click . Select "Catalog" in the context menu that appears to select an image representing the action.
- In the image catalog window, type "Map" in the search control and press Enter.
- Double-click the image you want to select.
- In the image configuration window, select a size (80 for example, W (Width) = 80 and H (Height) = 80), give a name to the image (e.g. "MapOfStores") and validate.
- Validate the description window.
To change the text in the second row of the Multiline Zone control: - Click the Static Text control in the second row.
- Open the description window (double-click the control).
- In the "General" tab of the description window:
- Give a name to the control ("STC_MapOfStores", for example).
- Change the caption ("Map of stores", for example).
- Validate the description window.
Modification of 3rd line: exit the application To change the image in the third row of the Multiline Zone control: - Click the Image control in the third row.
- Open the image description window (double-click the control).
- In the description window:
- Give a name to the image ("IMG_Exit", for example).
- Click . Select "Catalog" in the context menu that appears to select an image representing the action.
- In the image catalog window, type "Close" in the search control and press Enter.
- Double-click the image you want to select.
- In the image configuration window, select a size (80 for example, W (Width) = 80 and H (Height) = 80), give a name to the image (e.g. "Close") and validate.
- Validate the description window.
To change the text in the third row of the Multiline Zone control: - Click the Static Text control in the third row.
- Open the description window (double-click the control).
- In the "General" tab of the description window:
- Give a name to the control ("STC_Exit", for example).
- Change the caption ("Exit application", for example).
- Validate the description window.
We will change the text style so that it is shown in black: - Click the Static Text control in the first row.
- Open the description window (Alt + Enter).
- On the "Style" tab, select the "Caption" element, expand "Font color" and select black.
- Confirm changes and close the description window.
- The text color changes automatically.
To repeat this action on the other Static Text controls: - Click the Static Text control in the second row.
- Press F4. This key repeats the last action. In this case, the text becomes black.
- Select the Static Text control in the third row and press F4 again.
Programming the menu Finally, we will write the WLanguage code necessary to perform each action in the menu: - Right-click the Multiline Zone control and select "Code".
Please note Make sure you select the Multiline Zone control field and not one of its component fields. - In the code editor, type the following WLanguage code in the "Select (click) a row in..." event:
SWITCH MZ_MENU
CASE 1
WIN_List_of_products.OpenMobileWindow()
CASE 2
WIN_Map_of_stores.OpenMobileWindow()
CASE 3
Close()
END
- Save changes by clicking in the quick access buttons.
- Close the code window (click the "X" icon in the upper-right corner of the code editor).
The last step consists in specifying that the menu window is the first window of the application. To do so, we will test the entire project and define the first window of the application. To define the first project window: - Select the "WIN_Menu" window in the "Project explorer" pane.
- Open the context menu.
- Select "First project window". A specific icon (with a small 1) appears to the left of the window name, in the "Project explorer" pane.
So far, we have tested the windows individually by clicking in the quick access buttons. We will now test the entire project. To start the project test on the simulator: - Click in the quick access buttons.
- Your project starts with the menu window. Click an option of your menu to check whether the different links are correct.
Completed project Do you want to check the end result of the steps described here?
A completed project is available. This project contains the different windows created in this lesson. To open the corrected project, on the home page, click on "Tutorial", then in the "Tutorial - Complete application with data" area, click on the "Open corrected project" link. In this lesson, we covered different aspects of the development of a mobile application: - adding and modifying records in a database,
- the use of a number of useful fields in a mobile application: RepeatString, map, multiline zone,
- using specific functionalities (camera, bar code, etc.).
We also saw the importance of anchoring controls. In the next lesson, we will see how to use layouts to obtain a completely different interface depending on the orientation.
|
|
|