summaryrefslogtreecommitdiff
path: root/dalos-input.lua
blob: bf37b9d297dd6c7cf9cec7a32619129ae60a6acd (plain)
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
dalosp.input = {   
    get_settings = function (self)
        return { filename = self.extra.filename }
    end,
    
    configure = function (self)
        local dlg = iup.filedlg {
            dialogtype = "Open",
            file = self.extra.filename,
        }
        iup.Popup(dlg)
        if dlg.status ~= -1 then
            local s, v = pcall(Input, dlg.value)
            if s then
                self:set_houtput(v)
                return
            end
        end
        self:set_houtput(nil)
    end,
    
    create = function (d, tab, settings)
        tab.ninputs = 0
        tab.noutputs = 1
        tab.otype = dalos.objtype.HANDLE
        tab.configure = dalosp.input.configure
        tab.default_name = "Input"
        tab.ntype = "Input"
        tab.get_settings = dalosp.input.get_settings
        local extra = { }
        if settings then extra.filename = settings.filename end
        local obj = dalos.object(d, tab, extra)

        if extra.filename then
            local s, v = pcall(Input, extra.filename)
            if s then obj:set_houtput(v) end
        end
        
        return obj
    end,
}

dalos.input = dalosp.input.create
dalos:register_obj("Input", dalos.input, "Basic Inputs")