- In this lesson you will learn the following concepts
- Overview
- Creating a Form window with swipe gesture support
- Creating the Form window
- Creating the internal window
- Swipe gesture in the Form window
- Window test
- Conclusion
Lesson 4.5. Enable swipe gesture on a window In this lesson you will learn the following concepts - Creating an internal window via a refactoring process.
- Changing the window content with a swipe gesture.
In Windows applications, all operations are performed with the mouse or keyboard. In mobile devices, interfaces must be designed differently. In touch screens, all operations are performed with the fingers. In applications for mobile devices, WINDEV Mobile offers multiple features to manage specific touch gestures (e.g., pull to refresh, double tap, sliding, etc.). In this lesson, we will create a new form window to view products. In this window, you will be able to navigate between product forms with a simple swipe gesture. | | |  | Answers | If you have not created the "WM Product Management" application, you can use the corrected project. This project contains all the windows created in this part and allows you to check your operations. To open the completed project, go to the home page and click "Tutorial", then in "Part 4 - Development of an Android/iOS application", double-click "Android/iOS product management (Answers)". |
Creating a Form window with swipe gesture support Creating the Form window - To create the form window:
- Create a new blank window.
- Click
in the quick access buttons. - The new element window appears: click "Window" then "Window".
- In the wizard, select the "Standard" tab, choose "Blank" and validate.
- In the window for saving an element, specify:
- the window title: "Product form".
- the window name: "WIN_Advanced_FORM_Product".
- Validate.
We will now create an Internal Window control in the "WIN_Advanced_FORM_Product" window. This control will contain an internal window that will display the data the user can navigate through. - To create the Internal Window control:
- On the "Creation" tab, in the "Containers" group, expand "Internal window" and select "Swipe area (internal window)".
- Click at the desired location to create the control in the window (upper-left corner).
- Resize the Internal Window control so that it occupies the entire available space in the window.
- Change the anchors of the Internal Window control (select "Anchor" in the context menu): anchor the control vertically and horizontally (
). - Validate.
Creating the internal window - To easily create the internal window, we will create it from the "WIN_Product_form" window of our project:
- If necessary, open "WIN_Product_form" in the editor (double-click its name in the "Project explorer" pane).
- Select all controls in the portrait layout (Ctrl + A).
- Open the context menu and select "Refactoring .. Create an internal window from the selection".
- The internal window is automatically created and the save window is displayed. Name the window "IW_Product" and validate.
- Open the internal window that we have just created in the editor: click "IW_Product" in the open document tabs.
- Open the description of the internal window. In the "UI" tab, change the window width: 360. This width corresponds to the width of the Internal Window control that we created in "WIN_Advanced_FORM_Product".
- Validate.
Swipe gesture in the Form window - To associate the internal window with the Form window:
- Open the "WIN_Advanced_FORM_Product" window in the editor (click on it in the open document tabs).
- Select the Internal Window control and open its description ("Description" in the context menu).
- In the "General" tab, select the internal window ("IW_Product").
- In the "UI" tab, in the "Swipe to change content" section:
- The "Allow swipe to change content" option is already checked because we have chosen the Internal Window control to swipe the content.
- Check "Position on the current record when opening the internal window.".
- The swipe orientation is "Horizontal" by default.
- In the "Content" tab, we will set how the internal window will be populated. This window will display the data of the Product data file:
- Click "File/Query".
- In the source, for the "Browsed file" option, select the "Product" data file.
- Validate the description window.
We have completed the swipe gesture configuration. - To prevent the keyboard from appearing during the swipe gesture, we will use SIPVisible:
- Open the WLanguage events of the Internal Window control located inside "WIN_Advanced_FORM_Product".
- Write the following code in the "Selection by swipe ..." WLanguage event:
- Close the code editor.
- To finish this window, we are going to add the validation option to the Action Bar. We have already done this in lesson 4.2 ("Creating and modifying a product"). Here, we will only present the main points:
- Select the Action Bar (at the top of the window).
- Open the Action Bar description window.
- Click number 2. The interface for editing options in the Action Bar appears.
- Click the "+" button to add an option. A new option is created at the top right.
- Change the characteristics of this option:
- In the "Caption" area, type "Done".
- In the "Preset image" area, expand the list and select "Done".
- Validate the description window.
- To enter the code that saves the changes made to the "WIN_Advanced_FORM_Product" window:
- Select the Action Bar control.
- Click "OK".
- A drop-down menu with the "Done" 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:
ScreenToFile() Product.Save() Close()
- 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).
Before testing the window, we are going to modify the "WIN_Advanced_FORM_Product" window to directly open the form window that we have just created. - To open the form window from the list of products:
- Open the "WIN_Advanced_LIST_Products" window in the editor (click on it in the open document tabs).
- Open the WLanguage events related to the Looper control.
- In the "Selecting a row ... " event, replace the following WLanguage code:
Product.ReadSeek(ProductID,QRY_Products.ProductID) WIN_Product_form.OpenMobileWindow()
with
Product.ReadSeek(ProductID,QRY_Products.ProductID) WIN_Advanced_FORM_Product.OpenMobileWindow()
- We are going to test the project in the simulator:
- Click
in the quick access buttons. - In the Looper control that is displayed, click a product to see the details.
- Click the product form and move the mouse to the right or to the left. The product form automatically changes.
This part explained the main concepts for developing Android or iOS applications. Several themes have not been presented in this part: - managing emails,
- managing notifications,
- using the visualization panel,
- using the debugger,
- ...
See the online help to discover and check new features.
|
|
|
|