-
Notifications
You must be signed in to change notification settings - Fork 241
Closed
Description
Wouldn't executing events/callbacks immediatelly (after changing state by kerboscript) be more understandable and usefull (e.g. for custom radio groups spread over multiple boxes)?
local wnd is gui(0).
local bt1 is wnd:addButton("TEST").
local bt2 is wnd:addButton("OTHER").
set bt1:toggle to true.
set bt2:toggle to true.
local counter is 0.
local function click {
parameter me.
parameter it.
parameter on.
if on set it:pressed to false.
set counter to counter+1.
print counter+"."+me:text+"="+on.
}
set bt1:onToggle to click@:bind(bt1,bt2).
set bt2:onToggle to click@:bind(bt2,bt1).
wnd:show().
wait until counter > 10.
wnd:dispose().
Output:
1.TEST=True
2.OTHER=True
3.TEST=False
Would require changing TriggerNextUpdate to CallPassingArgs, probably.
And btw, the code will crash until you accept #2238
https://ksp-kos.github.io/KOS/structures/gui.html#gui-callback-technique
will interrupt whatever else you are doing and call a function you wrote called myClickFunction whenever that button is clicked.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels