Client-side Events in Smart DevicesOfficial Content

As we saw in Smart Device Events, client events are the programmatic response of the application to user interaction. These forms of interaction are called Smart Devices Actions and can be seen in on-screen buttons, images, or other controls that when tapped, long tapped, etc., will execute the event associated to the action.

Mainly we have two types of client events: user and control events. Both are associated to controls. The slight difference is while the former have a name given by the developer and then associated to the controls themselves (with the tap gesture as the way to trigger them); the latter are automatically predefined, depending on control type, having, in the case of touch control events, the event itself as the way to trigger them (e.g. control.LongTap event). Other kinds of control events are, for example, control.PageChanged event (when control is a grid of certain control type), or control.ControlValueChanged event (when control is a readOnly attribute or variable).

Client events allow developers to add behavior and logic to the application mixing the execution between the client side and server side. As mentioned in Smart Device EventsStartRefresh and Load are server events executed completely on the server, which means that they cannot use any of the resources of the device. In client events we can mix the power of the server and the resources of our device.

What happens when user triggers an action (client event)? The associated code is executed in the client side, that is, in the device, unless a roundtrip to the server is required (for example, when a procedure must be invoked). In any case, system events are not executed (unless they are explicitly required through the Refresh command).

So what can we do in a user event?

  • Call Rest Web Services:
  • WW EditCall a Work With for Smart Devices Detail node in order to Insert, Update or Delete information:
    • WorkWithDevicesObject.levelname.Detail.Insert( &bc )
    • WorkWithDevicesObject.levelname.Detail.Update( primaryKey )
    • WorkWithDevicesObject.levelname.Detail.Delete( primaryKey )
  • View:
  • Invoke the external objects of the Smart Devices API. E.g.
    • Msg( &var)                                      //Interop
    • Confirm (&var)                               //Interop
    • Return                                            //SDActions
    • Refresh                                         //SDActions
    • AddressBook.AddContact( ...)
    • etc.
  • Call a Web Panel object by means of the Component Domain (displays a web page, that is, the device web navigator will be executed, loading the web panel without showing navigator's frame, that can be recovered if the user wishes to do so).
  • Commands:
    • Composite
    • Some control properties assignments depending on the control (they are not the same as on the web). E.g.: Control.visible = ... | Control.class = ... (when user enters the control name followed by a dot (".") an intellitip is opened showing all possibilities for this control).
    • Simple variable assignation. E.g.
      • &Var = "Test"  / &Var = 123  /  &Var = proc.Udp()
    • Use SDT or BC based variables element assignation. E.g.
      • &SDT.Item  /  &Var = &SDT.Item / &BC.item = ...
    • Execute For Each Line / selected line" commands in grids with multiple selection.
    • Use IF-ELSE-ENDIF code block, with the restriction that you cannot use complex expressions on the conditions such as calling Procedures or External Objects methods; only simple conditions are allowed using variables, attributes or SDT members, and involving operators and standard functions.
    • Do While command. The block do while  - enddo is supported in user events in SD.

All these (and their combinations) can be used in a Client event. Remember to use the Composite command when trying to concatenate more than one action in client events.


Start Video Work With for Smart Devices – Behavior through Events
Start Video Events in Smart Devices

See also

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.