svghmi/widget_tooglebutton.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 06 Sep 2022 21:06:36 +0200
branchwxPython4
changeset 3589 a0b645a934c9
parent 3520 b27e50143083
child 3596 9c725829d8f0
permissions -rw-r--r--
OPC-UA, IDE: add CTN parameters to support OPC-UA encryption and authentication.

xmlclass had to be enhanced to support elements with no content in xsd:choice
2977
82f062408e70 SVGHMI: Added widget toggleButton.
dgaberscek
parents:
diff changeset
     1
// widget_tooglebutton.ysl2
82f062408e70 SVGHMI: Added widget toggleButton.
dgaberscek
parents:
diff changeset
     2
3011
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
     3
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     4
widget_desc("ToggleButton") {
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     5
    longdesc
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     6
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     7
    Button widget takes one boolean variable path, and reflect current true
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     8
    or false value by showing "active" or "inactive" labeled element
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     9
    respectively. Clicking or touching button toggles variable.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    10
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    11
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    12
    shortdesc > Toggle button reflecting given boolean variable
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    13
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    14
    path name="value" accepts="HMI_BOOL" > Boolean variable
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    15
    
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    16
}
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    17
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3219
diff changeset
    18
widget_class("ToggleButton") {
3011
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    19
    ||
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    20
        frequency = 5;
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    21
        state = 0;
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    22
        active_style = undefined;
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    23
        inactive_style = undefined;
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    24
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    25
        dispatch(value) {
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    26
            this.state = value;
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    27
            //redraw toggle button
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    28
            this.request_animate();
3011
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    29
        }
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    30
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    31
        on_click(evt) {
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    32
            //toggle state and apply
3219
cc0ecc5e918f SVGHMI: Code cleanup for ToggleButton.
Edouard Tisserant
parents: 3059
diff changeset
    33
            this.state = this.state ? false : true;
3018
Edouard Tisserant
parents: 3011
diff changeset
    34
            this.apply_hmi_value(0, this.state);
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    35
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    36
            //redraw toggle button
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    37
            this.request_animate();
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    38
        }
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    39
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3056
diff changeset
    40
        animate(){
3219
cc0ecc5e918f SVGHMI: Code cleanup for ToggleButton.
Edouard Tisserant
parents: 3059
diff changeset
    41
            // redraw toggle button on screen refresh
3520
b27e50143083 SVGHMI: generalize detach/re-attach of binary choices for ToggleButton, PushButton, Button and Keypad's Shit and CapsLock.
Edouard Tisserant
parents: 3519
diff changeset
    42
            this.set_activation_state(this.state);
3011
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    43
        }
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    44
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    45
        init() {
3219
cc0ecc5e918f SVGHMI: Code cleanup for ToggleButton.
Edouard Tisserant
parents: 3059
diff changeset
    46
            this.element.onclick = (evt) => this.on_click(evt);
3520
b27e50143083 SVGHMI: generalize detach/re-attach of binary choices for ToggleButton, PushButton, Button and Keypad's Shit and CapsLock.
Edouard Tisserant
parents: 3519
diff changeset
    47
            this.set_activation_state(undefined);
3011
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    48
        }
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    49
    ||
3024
Edouard Tisserant
parents: 3018
diff changeset
    50
}
3011
601c6dbc1da7 Reworked togglebutton widget to extand class widget
usveticic
parents: 3004
diff changeset
    51
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3219
diff changeset
    52
widget_defs("ToggleButton") {
3520
b27e50143083 SVGHMI: generalize detach/re-attach of binary choices for ToggleButton, PushButton, Button and Keypad's Shit and CapsLock.
Edouard Tisserant
parents: 3519
diff changeset
    53
    activable();
3004
705e34c6fe93 SVGHMI: More JS code refactoring : change_hmi_value and apply_hmi_value now methods of widget class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2977
diff changeset
    54
}
3519
43b2bff95289 SVGHMI: also use order-preserving detach re-attach for hiding and showing active and inactive state.
Edouard Tisserant
parents: 3495
diff changeset
    55