GUI enabling/disabling of controls: Difference between revisions

m (added whitespace before the TOC.)
Line 1,442:
$app.run;</lang>
 
=={{header|Phix}}==
Note: this validates each input char separately, and '-' is not "NUMBER": the only way to get numbers <0 or >9 into the input field is to paste them.
<lang Phix>include pGUI.e
 
Ihandle txt, inc, dec, hbx, vbx, dlg
 
function activate(integer v)
IupSetInt(txt,"VALUE",v)
IupSetAttribute(inc,"ACTIVE",iff(v<10,"YES":"NO"))
IupSetAttribute(dec,"ACTIVE",iff(v>0,"YES":"NO"))
IupSetAttribute(txt,"ACTIVE",iff(v=0,"YES":"NO"))
return IUP_CONTINUE
end function
 
function valuechanged_cb(Ihandle /*ih*/)
return activate(IupGetInt(txt,"VALUE"))
end function
 
function inc_cb(Ihandle /*ih*/)
return activate(IupGetInt(txt,"VALUE")+1)
end function
 
function dec_cb(Ihandle /*ih*/)
return activate(IupGetInt(txt,"VALUE")-1)
end function
 
function esc_close(Ihandle /*ih*/, atom c)
return iff(c=K_ESC?IUP_CLOSE:IUP_CONTINUE)
end function
 
IupOpen("../pGUI/")
txt = IupText("VALUECHANGED_CB",Icallback("valuechanged_cb"),"FILTER=NUMBER, EXPAND=YES")
inc = IupButton("increment",Icallback("inc_cb"))
dec = IupButton("decrement",Icallback("dec_cb"),"ACTIVE=NO")
hbx = IupHbox({inc,dec},"MARGIN=0x10, GAP=20")
vbx = IupVbox({txt,hbx},"MARGIN=40x20")
dlg = IupDialog(vbx)
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
IupShow(dlg)
IupMainLoop()
IupClose()</lang>
 
=={{header|PicoLisp}}==
Line 1,463 ⟶ 1,505:
(server 8080 "!start")
(wait)</lang>
 
 
=={{header|Prolog}}==
7,794

edits