WML Learning (vi): Events

Source: Internet
Author: User
Tags prev reset version variable
Event
WML events are basically divided into two categories, one is the keyboard (including soft and hard button) input events, with the <do> tag to deal with, the other is related to the internal page events, with the <onevent> tag to deal with.

The <do> syntax is as follows: <do type= "type" label= "label" name= "name" optional= "False|true" > Task </do> The task is the four tasks mentioned previously. In <do> properties, type is required and the other is optional.
*label property that specifies the text that the soft button displays on the screen. This property is not valid when the Type property is Delete,help,prev.
*name property, for <do> name, the same card in the <do> can not duplicate. If the card-level <do> and deck <do> have the same name, overwrite the deck-level <do>.
*optional property, specifies whether the phone can ignore this event, and the default value is False.
*type property, specifies the event that is triggered, as follows;
Type value trigger Reason
Accept Call Accept button mechanism
Delete call Delete button mechanism
Help invokes the Help button mechanism
Options call Select button Mechanism
Prev Call prev button mechanism
Reset mechanism (currently not supported) reset call to erase and reset phone status
Unknown calls the unknown mechanism, equal to Type= "" (not currently supported)
Vnd. Co-type calls vendor-specific mechanisms (not currently supported)
x-*, x-* for later use (not reserved) (not currently supported)

Test6.wml
---------------
<?xml version= "1.0"?>
<! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml" >

<wml>
<meta http-equiv= "Cache-control" content= "max-age=0"/>
<card id= "Card0" ordered= "false" >
<do type= "Accept" label= "InputName" name= "Do1" >
<go href= "#card01"/>
</do>
<p>
Name:<input name= "UserName" title= "User name" type= "text" format= "*m" emptyok= "false" maxlength= ""/>
</p>
</card>
<card id= "CARD01" >
<p>
Your name is $ (USERNAME:NOESC).
</p>
</card>
</wml>

The <onevent> syntax is as follows, <onevent type= "type" > Task </onevent&gt, and the required attribute type has the following values:
Type value performs a task if the user performs the following actions
Onpick the user chooses or does not select a <option>.
Onenterforward users use <go> tasks to arrive at a card.
Onenterbackward users use <prev> tasks to return to the previous card, or press the Back button.
OnTimer when <timer> expires.

Test7.wml
---------------
<?xml version= "1.0"?>
<! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml" >

<wml>
<meta http-equiv= "Cache-control" content= "max-age=0"/>
<card id= "Card0" ordered= "false" >
<p>
Please select a city ...
<select title= "Cities List" Name= "City" >
<option title= "Beijing" value= "Beijing" >
<onevent type= "Onpick" >
<go href= "#card01"/>
</onevent>Beijing</option>
<option title= "Shanghai" value= "Shanghai" onpick= "#card01" >Shanghai</option>
<option title= "Hongkong" value= "Hongkong" onpick= "#card01" >Hongkong</option>
</select>
& lt;/p>
</card>
<card id= "CARD01" >
<p>
Are living in $ (CITY:NOESC)
</p>
</card>
</wml>

<timer/> can be used to automate a task after a period of time when the user does nothing, and any task and user action that activates the card page will start <timer/&gt, and,<timer/> will stop when the task is in progress. Each card can have only one <timer/&gt, and a <timer/> can only trigger one task. The syntax is as follows: <timer name= "variable" value= "value"/&gt, where name is an optional attribute, specified as a variable name, and when exiting the card, the variable stores the value of the timer at this time, and when the timer times out, the cell phone sets the variable to 0 The value is a required attribute that sets the timer's timing value, with a minimum unit of 0.1 seconds.

Test8.wml
---------------
<?xml version= "1.0"?>
<! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml" >

<wml>
<meta http-equiv= "Cache-control" content= "max-age=0"/>
<card id= "Card1" ontimer= "#card2" >
<timer name= "time1" value= "/>"
<p align= "center" >
After 5s, Goto CARD2
</p>
</card>
<card id= "Card2" >
<onevent type= "OnTimer" >
<go href= "#card1"/>
</onevent>
<timer name= "time2" value= "/>"
<p align= "center" >
This is card2!
</p>
</card>
</wml>

Just to mention it.,<onevent> <timer> <do> must be written in the order listed above.

In addition, &LT;TEMPLATE&GT can be added at the deck level to bind the event to the deck level, the syntax is as follows:
<template onenterforward= "url" onenterbackward= "url" ontimer= "url" >
<do> or <onevent>
</template>


Test9.wml
---------------
<?xml version= "1.0"?>
<! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml" >

<wml>
<meta http-equiv= "Cache-control" content= "max-age=0"/>
<template>
<do type= "Accept" label= "deckpress" name= "Do1" >
<go href= "#card01"/>
</do>
</template>
<card id= "Card0" ordered= "false" >
<do type= "Accept" label= "cardpress" name= "Do1" >
<go href= "#card02"/>
</do>
<p>
Press ACCEPT ...
</p>
</card>
<card id= "CARD01" >
<p>
This is CARD01
</p>
</card>
<card id= "CARD02" >
<p>
This is CARD02
</p>
</card>
</wml>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.