New sample: Combobox

combobox

combobox (click to open live demo)

Source code (application written with Visual Application Designer):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function main(app)
{
    var workarea = app.create("dialog");
    workarea.Title = "Workarea";
    workarea.Width = 365;
    workarea.Height = 170;
    workarea.DialogPosition = {at: "center"};
 
    var combobox = app.create("combobox", workarea);
    combobox.Top = 12;
    combobox.Left = 12;
    combobox.Position = "absolute";
    combobox.Width = 205;
    combobox.Height = 22;
    combobox.Border = "";
    combobox.Items = [{"key": "key1", "value": "value1"},
                      {"key": "key2", "value": "value2"},
                      {"key": "key3", "value": "value3"}];
    combobox.on("change", function(myself, key){
            // updates the textfield with current key
            textfield4.Text = key;
            console.log("on change - key:", combobox.Selected);
        });
 
    var button1 = app.create("button", workarea);
    button1.Top = 10;
    button1.Left = 225;
    button1.Position = "absolute";
    button1.Caption = "Clear";
    button1.Width = 100;
    button1.Height = 22;
    button1.Border = "";
    button1.on("click", function(){
            combobox.clear();
        });
 
    var button2 = app.create("button", workarea);
    button2.Top = 40;
    button2.Left = 225;
    button2.Position = "absolute";
    button2.Caption = "Add Item";
    button2.Width = 100;
    button2.Height = 22;
    button2.Border = "";
    button2.on("click", function(){
            combobox.addItem(/* key*/ textfield2.Text, /* value */ textfield3.Text);
        });
 
    var button3 = app.create("button", workarea);
    button3.Top = 70;
    button3.Left = 225;
    button3.Position = "absolute";
    button3.Caption = "Remove Item";
    button3.Width = 100;
    button3.Height = 22;
    button3.Border = "";
    button3.on("click", function(){
            combobox.removeItem(/* key*/ textfield4.Text);
        });
 
    var textfield2 = app.create("textfield", workarea);
    textfield2.Top = 40;
    textfield2.Left = 10;
    textfield2.Position = "absolute";
    textfield2.Text = "key";
    textfield2.Width = 80;
    textfield2.Height = 17;
    textfield2.Border = "";
 
    var textfield3 = app.create("textfield", workarea);
    textfield3.Top = 40;
    textfield3.Left = 95;
    textfield3.Position = "absolute";
    textfield3.Text = "value";
    textfield3.Width = 118;
    textfield3.Height = 17;
    textfield3.Border = "";
 
    var textfield4 = app.create("textfield", workarea);
    textfield4.Top = 70;
    textfield4.Left = 10;
    textfield4.Position = "absolute";
    textfield4.Text = "key";
    textfield4.Width = 80;
    textfield4.Height = 17;
    textfield4.Border = "";
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *