-
Notifications
You must be signed in to change notification settings - Fork 241
Closed
Description
EDIT: was able to make smaller example, after I looked in to the code
and I think that CPU.AddTrigger should merge in PreBoundArgs
local wnd is gui(0).
local btn is wnd:addButton("TEST").
local function click {
parameter text.
print text.
}
set btn:onClick to click@:bind("TEST").
wnd:show().
wait until btn:takePress.
wnd:dispose().
ORIGINAL:
local wnd is gui(200).
local function init {
parameter item.
parameter width is 0.
parameter stretch to true.
parameter align is "center".
set item:style:align to align.
set item:style:width to width.
if width = 0 set item:style:hstretch to stretch.
return item.
}
local function button {
parameter wnd.
parameter text.
parameter width is 0.
parameter stretch to true.
parameter align is "center".
return init(wnd:addButton(text), width, stretch, align).
}
local function radio {
parameter lst.
parameter btn.
lst:add(btn).
set btn:toggle to true.
return btn.
}
local dir is list().
local row is wnd:addHLayout().
local dirPro is radio(dir,button(row,"Prograde",100)).
local dirRet is radio(dir,button(row,"Retrograde",100)).
local row is wnd:addHLayout().
local dirUnl is radio(dir,button(row,"UNLOCK",100)).
local done is button(row,"CLOSE",100).
local function uncheck {
parameter lst.
parameter except.
for btn in lst if btn <> except set btn:pressed to false.
}
local function check {
parameter lst.
parameter btn.
uncheck(list, btn).
set btn:pressed to true.
}
local function onToggle {
parameter lst.
parameter def.
parameter btn.
parameter fn.
parameter on.
if on { uncheck(lst,btn). fn(). }
else {
for b in lst if b:pressed return.
set def:pressed to true.
}
}
local function bindToggle {
parameter btn.
parameter fn1.
parameter fn2.
set btn:onToggle to { parameter on. fn1(btn,fn2,on). }.
return btn.
}
local function bindToggle2 {
parameter btn.
parameter fn1.
parameter fn2.
set btn:onToggle to fn1:bind(btn,fn2).
return btn.
}
local dirToggle is onToggle@:bind(dir,dirUnl).
bindToggle(dirPro, dirToggle, { sas off. lock steering to srfPrograde. }).
bindToggle2(dirRet, dirToggle, { sas off. lock steering to srfRetrograde. }).
bindToggle(dirUnl, dirToggle, { unlock steering. sas on. }).
set dirUnl:pressed to true.
wnd:show().
wait until done:takePress.
wnd:dispose().
unlock all.
Try pressing Prograde and UNLOCK and that works, because these two are created by bindToggle, but then try Retrograde which is bound by bindToggle2, which should work the same... or not?
local dirToggle is onToggle@:bind(dir,dirUnl). should bind parameters lst and def leaving btn,fn,on. Then bindToggle should bind btn and fn leaving on for the call. bindToggle and bindToggle2 should do the same thing... or not?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels