<< 点击显示目录 >> 主页 mappView帮助助手 > mappView入门简单Wiki > 具有短按和长按事件的按钮 Button with short and long press event |
•Automation Studio 4.4
•mappView 5.5
此示例显示如何创建一个生成短按和长按事件的按钮。
•创建一个新计时器
•在 mappView 中添加一个新按钮
创建一个新的计时器
在mappView Configuration(1)中根据以下窗口添加一个新的定时器(2)
在 mappView 中添加一个新按钮
在 mappView 中添加一个新的标准按钮,并将以下代码添加到事件绑定文件中。
<!-- Start new timer on mouse down event />-->
<EventBinding id="Main.Button1.MouseDown">
<Source contentRefId="Main" widgetRefId="Button1" xsi:type="widgets.brease.Button.Event" event="MouseDown" />
<EventHandler>
<Action>
<Target xsi:type="session.TimerAction" refId="LongPress" >
<Method xsi:type="session.TimerAction.Start" />
</Target>
</Action>
</EventHandler>
</EventBinding>
<!-- This is the long press event when the timer runs to the end />-->
<EventBinding id="LongPress" >
<Source xsi:type="session.Timer.Event" refId="LongPress" event="Elapsed"/>
<EventHandler>
<Sequence>
<!-- Reset timer />-->
<Step order="0">
<Action>
<Target xsi:type="session.TimerAction" refId="LongPress" >
<Method xsi:type="session.TimerAction.Stop" />
</Target>
</Action>
</Step>
<!-- Open a dialog box />-->
<Step order="1">
<Action>
<Target xsi:type="clientSystem.Action">
<Method xsi:type="clientSystem.Action.OpenDialog" dialogId="DialogSelectionMachine" />
</Target>
</Action>
</Step>
</Sequence>
</EventHandler>
</EventBinding>
<!-- This is the short press event when the mouse goes up before the timer finishes />-->
<EventBinding id="Main.Button1.MouseUp">
<Source contentRefId="Main" widgetRefId="Button1" xsi:type="widgets.brease.Button.Event" event="MouseUp" />
<!-- Read timer status />-->
<Operand name="IsRunning" datatype="BOOL">
<ReadTarget xsi:type="session.TimerAction.Read" refId="LongPress" >
<Method xsi:type="session.TimerAction.IsRunning" />
</ReadTarget>
</Operand>
<EventHandler condition="IsRunning=true">
<Sequence>
<!-- Reset timer />-->
<Step order="0">
<Action>
<Target xsi:type="session.TimerAction" refId="LongPress" >
<Method xsi:type="session.TimerAction.Stop" />
</Target>
</Action>
</Step>
<!-- Switch to next page />-->
<Step order="1">
<Action>
<Target xsi:type="clientSystem.Action">
<Method xsi:type="clientSystem.Action.Navigate" pageId="DataPage" />
</Target>
</Action>
</Step>
</Sequence>
</EventHandler>
</EventBinding>