Command and Trigger

Command

  • Command:Basic commands, you can control the interface in the other elements by properties of the object and the object's name. Usually it controls the visibility (visibility) and animation elements (animation).
    <Command target = "iamge1.visibility" value = "false" condition = "" delay = "" delayCondition = "" />
    <Command target = "iamge1.animation" value = "play" condition = "" delay = "" delayCondition = "" />
    
  • iamge1 is the name of the object to be controlled ".", followed by an attribute (currently visibility and animation).
  • Control visibility when, value which is written true or false, control the animation when, value write play (currently not supported so that movie is paused)
  • condition is conditional, support for regular expressions. When the condition where the condition is true, execute the command; is false, not executed.
  • delay is the delay, in milliseconds. After reading the order a period of time delay execution
  • delayCondition judgment is delayed, after the delay of time to judge.
  • Example:
    <Button x = "0" y = "0" h = "100" w = "100">
         <Triggers>
             <Trigger action = "down">
                 // Second <40, 2000ms delay execution
                 <VariableCommand name = "delayCond0" expression = "# delayCond0 + 5" condition = "lt (# second, 40)" delay = "2000" />
                 // Delay after 6000ms, if the second <40, perform
                 <VariableCommand name = "delayCond1" expression = "# delayCond1 + 5" delayCondition = "lt (# second, 40)" delay = "6000" />
                 // Second <40, the delay 4000ms, at this time if the second <40, perform
                 <VariableCommand name = "delayCond2" expression = "# delayCond2 + 5" condition = "lt (# second, 40)" delayCondition = "lt (# second, 40)" delay = "4000" />
             </ Trigger>
         </ Triggers>
    </ Button>
    

VariableCommand

VariableCommand, used to control the variable (Var) value. Including the name and expression are two special attributes, condition, delay, delayCondition usage consistent with the Command

// The width value screen is assigned to w
<VariableCommand name = "w" expression = "# screen_width" />

SoundCommand

Voice commands can be used to play audio files

<SoundCommand sound = "" volume = "" loop = "" keepCur = "" />
  • sound: sound file name
  • volume: size of the sound, a floating-point number between 0 and 1
  • loop: if the loop, true / false, default is false.
  • keepCur: When playing this audio, whether to keep the currently playing sound, true / false, default false. Note: The sound file size requirements do not exceed 500kB, lasts no more than 10 seconds (10 seconds after the sound does not come out to play).
    // Loop reached.mp3, while constantly being played out other sounds
    <SoundCommand sound = "reached.mp3" volume = "1" loop = "true" keepCur = "true" />
    

    ExternCommand

  • General command, used to send commands to external programs
    <ExternCommand command = "command name" numPara = "parameter 1, numeric expressions," strPara = "parameter 2, string expression" />
    
  • A command can now use the unlock command (only valid in the lock screen)
    <ExternCommand command = "unlock" />
    
  • With this command the unlocking operation can be achieved without the use of

ExternalCommand

And ExternCommand contrast, is used to receive an external command command, typical usage: in the lock screen, typically used to receive the opening screen / off-screen commands to execute some commands; the desktop plug-in to detect cut screen to perform command Examples

resume indicates that the command executed when the opening screen, pause indicates that the command is executed when off-screen
<ExternalCommands>
<Trigger action = "resume">
         <Command target = "target.animation" value = "play" />
        </ Trigger>
   <Trigger action = "pause">
      <VariableCommand name = "pause_time" expression = "# time_sys" />
  </ Trigger>
</ ExternalCommands>
Sample desktop plug-cut screen use
<ExternalCommands>
    <Trigger action = "resume">
       <Command target = "__ root.animation" value = "play" />
    </ Trigger>
    <Trigger action = "pause">
        <Command target = "__ root.animation" value = "play" />
    </ Trigger>
</ ExternalCommands>

Examples of Command

  • Use the buttons to achieve switch

    <! - Each Button can have a number of Command ->
    <Button x = "10" y = "10" w = "100" h = "100">
    <Triggers>
       <Trigger action = "up">
          <Command target = "Wifi" value = "toggle" />
       </ Trigger>
    </ Triggers>
    
    <Pressed>
       <Image x = "10" y = "10" src = "toggle_btn_pressed.png" />
    </ Pressed>
    
    <Normal>
       <Image x = "10" y = "10" src = "toggle_btn_normal.png" />
    </ Normal>
    </ Button>
    
  • Bluetooth value = "on" value = "off"

    <Command target = "Bluetooth" value = "toggle" />
    
  • data ```xml

<! - Switch to only open, with another button to switch to the OFF ->


* Ring / mute / vibration
```xml
<-! Value = "normal, silent, vibrate" value = "silent" value = "normal" <br>
      In a comma-separated state key switch, you can specify only one state, each of the plurality of button status value with a different value, you can quickly switch to the desired state ->
Three states switched
<Command target = "RingMode" value = "toggle" />

Below and above the same effect
<Command target = "RingMode" value = "normal, silent, vibrate" />

Only normal and mute switch
<Command target = "RingMode" value = "normal, silent" />

Only normal and shock switch
<Command target = "RingMode" value = "normal, vibrate" />

Only switches to mute other button to switch to another state
<Command target = "RingMode" value = "silent" />
  • USB storage toggle / on / off ```xml

* Wifi toggle / on / off
```xml
<Command target = "Wifi" value = "toggle" />
  • A sliding manner to achieve the switching
    <Slider name = "switch_usb_mode" bounceInitSpeed ​​= "500" bounceAcceleration = "1500" alwaysShow = "true" visibility = "# usb_mode">
    <StartPoint x = "0" y = "0" w = "100" h = "100">
       <NormalState>
       </ NormalState>
    </ StartPoint>
    <EndPoint x = "340" y = "0" w = "100" h = "100">
       <Command target = "UsbStorage" value = "toggle" />
       <Path>
          <Position x = "0" y = "0" />
          <Position x = "340" y = "0" />
       </ Path>
    </ EndPoint>
    </ Slider>
    
    • State variables, only add the appropriate command after the effective
      • #ring_mode: 0 silent, 1 vibrate, 2 normal
      • #wifi_state: 0 disabled, 1 enabled, 2 problem, 3 half (intermediate)
      • #bluetooth_state: 0 off, 1 on, 2 half
      • #data_state: 0 off, 1 on
      • #usb_mode: 0 disconnected, 1 charge only, 2 storage, 3 intermediate

Trigger

  • Trigger the Command support variable assignment

    <VariableCommand name = "test" expression = "# test + 1" />
    name: variable name, expression: assignment expression
    
  • Trigger Command support movie playback control ```xml

    <VariableCommand name = "gesture_valid" expression = "ge (abs (#gesture_offset), 80)" />
    <VariableCommand name = "ani_begin_x_add" expression = "ifelse (lt (# current_screen, # screenview_count-1), # gesture_offset + # screenview_w, # gesture_offset)" />
    <VariableCommand name = "ani_begin_x_dec" expression = "ifelse (gt (# current_screen, 0), # gesture_offset- # screenview_w, # gesture_offset)" />
    <VariableCommand name = "ani_begin_x" expression = "ifelse (# gesture_valid, ifelse (# gesture_offset, # ani_begin_x_dec, # ani_begin_x_add), # gesture_offset)" />
    <VariableCommand name = "touch_x" expression = "# touch_begin_x" />
    <Command target = "ani_offset_x.animation" value = "play" />
    

    </ Trigger> </ Triggers> </ Button>

</ VariableAnimation> </ Var> ```

results matching ""

    No results matching ""