---
title: "跨平台移动应用程序中的事件处理和控制流程定义"
date: "2015-06-17"
categories: 
  - "applications"
  - "mobile"
tags: 
  - "mobile"
  - "mobile-development"
  - "mobiletogether"
  - "software-tools"
description: 探索如何利用 Altova MobileTogether 简化跨平台移动应用程序中的事件处理和控制流程，从而实现快速开发，而无需针对特定设备的编码。
---
Status: #blog

Tags:  #mobile #mobile-development #mobiletogether #software-tools

Categories: [low-code+no-code](/blog/zh/category/low-codeno-code.md) | [mobile-development](/blog/zh/category/mobile-development.md)
# 跨平台移动应用程序中的事件处理和控制流程定义

Altova MobileTogether 能够帮助任何规模的企业，快速设计和部署适用于所有移动平台的 [定制企业移动解决方案](https://www.altova.com/zh/mobiletogether.html)。MobileTogether Designer 中的“操作”对话框是其关键特性之一，它使得企业能够在几天内[开发出强大的移动解决方案](https://www.altova.com/zh/mobiletogether/develop-apps-fast.html)，而不是花费数月。

“操作”对话框允许开发者创建复杂的事件处理程序、控制流程和操作，这些操作在 iOS®、Android™、Windows® Phone 8 和 Windows 8 设备上，以及基于 HTML5 的浏览器客户端上，都能以相同的方式运行。开发者无需担心每个移动操作系统所特有的 API 或 SDK 的细节，因为使用 MobileTogether 构建的“操作树”不依赖于任何特定的设备相关编程语言。

![C0047146_700x335](/blog/images/C0047146_700x335.jpg)

<!--more--> For instance, to assign an event handling action to a button to respond to an OnButtonClicked event, the developer simply selects Control Actions from the context menu:

![在 MobileTogether 中定义按钮的功能](https://lh3.googleusercontent.com/-5cUZuv7PsKo/VXsk5zXsFjI/AAAAAAAACFQ/Ag1Oiu1_TsM/image%25255B2%25255D.png?imgmax=800 "Defining the Action of a Button in MobileTogether")

此菜单选项会打开“操作”对话框，其中可以在左侧选择一个或多个操作，然后将其拖动到右侧的编辑窗口中，在该窗口中可以以树状结构定义控制流程，并配置必要的详细信息。

![MobileTogether 操作对话框](https://lh3.googleusercontent.com/-mQPySaA-iRQ/VXsk6XhsKwI/AAAAAAAACFU/wVAbguTx0WM/ActionsList%25255B2%25255D.png?imgmax=800 "MobileTogether Actions Dialog")

例如，随附于 [MobileTogether Designer](https://www.altova.com/zh/mobiletogether/designer.html) 并安装在 MobileTogether 演示服务器上的“费用报告”示例解决方案包含一个按钮，允许用户拍摄费用收据的照片，并将照片包含在报告中。该按钮的操作树定义如下：

![MobileTogether 按钮操作定义](https://lh3.googleusercontent.com/-xgmxrKQJtQ4/VXsk6pH-KjI/AAAAAAAACFc/TIfJD1Q4To0/OnClickDefinition%25255B2%25255D.png?imgmax=800 "MobileTogether Definition of Button Actions")

分配的操作是“允许用户选择图像”，其中选择内置的移动设备摄像头作为来源，并将拍摄的第一个图像保存到文件 $TEMP-PHOTO 的节点 original-photo 中。

除了访问设备功能，如摄像头、电话、网页浏览器或地理位置信息之外，“操作”对话框还支持标准的控制流程，包括循环、if-then-else 决策结构以及数据库事务。 就像其他编程语言中的函数或过程一样，开发人员可以定义“操作组”，以定义一组操作，这些操作可以赋予描述性名称，并且易于重用，或者可以嵌套。 “操作组”可以通过将其拖动到编辑区域来调用，就像调用单个操作一样。

“操作”对话框还允许开发人员定义“页面操作”，这些操作在页面加载、重新打开、刷新时，或者当按下设备的“返回”按钮时执行。 “操作”定义为开发人员提供了对移动解决方案执行流程的完全控制。

![在 MobileTogether 中定义页面操作](https://lh3.googleusercontent.com/-9bnx89t_oRA/VXsk7E23rTI/AAAAAAAACFk/yj5gaPROeqc/PageActionsCapture%25255B2%25255D.png?imgmax=800 "Defining Page Actions in MobileTogether")

当解决方案使用 MobileTogether Designer 的 [模拟器功能](https://www.altova.com/blog/2015/01/a-cross-platform-simulator-for.html)运行时，在“消息”窗口中可以识别正在执行的“操作组”，并且会报告每个操作。

![在 MobileTogether 模拟器中跟踪操作执行](https://lh3.googleusercontent.com/-2ZFXCySUBJ4/VXsk7khEDFI/AAAAAAAACFs/mQybpz-4pe8/Executing%252520Action%252520Group%252520Capture%25255B2%25255D.png?imgmax=800 "Tracing Execution of Actions in the MobileTogether Simulator")

对于更深入的调试或对 MobileTogether 解决方案进行长期项目管理，MobileTogether 项目菜单包含一个选项，可以报告整个解决方案中“操作组”的使用情况。 可以在“消息”窗口中搜索此报告，也可以将其导出为文本文件。

![MobileTogether 操作组使用情况报告](https://lh3.googleusercontent.com/-HP236z-NRmA/VXsk79tF6OI/AAAAAAAACF0/Un3RFufFeKc/ActionGroupUsageCapture%25255B2%25255D.png?imgmax=800 "MobileTogether Action Group Usage Report")

“操作”不仅可以简单地提供对移动设备功能的访问。 在本文的第二部分，我们将讨论可以用来操作数据的“操作”，包括强大的工具，用于更新报告和移动 BI 仪表板，以及一种策略，用于构建一个数据集成模型，该模型可以随时扩展，以处理未知大小的数据集。

![MobileTogether 数据操作](https://lh3.googleusercontent.com/-zxsA1BkLL9M/VXsk8ZgXVkI/AAAAAAAACF8/6GbQqmOuRLI/DataActions%25255B2%25255D.png?imgmax=800 "MobileTogether Data Actions")

一系列简短的 [视频演示](https://www.altova.com/zh/mobiletogether/demos.html) 已发布在 [Altova 网站](https://www.altova.com/zh/mobiletogether/demos.html)上，演示了使用 MobileTogether Designer 创建移动企业应用程序的便捷性。 或者，请查看 [MobileTogether Designer 在线帮助](http://manual.altova.com/MobileTogether/mobiletogetherdesigner/)的网页版本，以获取更详细的信息。

**如果您想了解更多信息并下载免费的 MobileTogether Designer，以创建您的第一个面向 iOS®、Android™、Windows® Phone 8 和 Windows 8 以及 HTML5 浏览器客户端的企业移动解决方案，请访问：**

[**www.altova.com/mobiletogether**](https://www.altova.com/zh/mobiletogether)
