rem ' BBjControl::setAttribute Example
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,300,550,"Window",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
status! = window!.addStatusBar(100)
data "text","color","date","datetime-local","email","month"
data "number","range","search","tel","time","url","week"
i = 101, x = 100, y = 25, w = 175, h = 25
tbutton! = window!.addToolButton(1,x,y,w,h,"getText",$$)
tbutton!.setCallback(tbutton!.ON_TOOL_BUTTON_PUSH,"getText")
while 1
dread type$,err=*break
y = y + h + 10
window!.addStaticText(i+100,0,y+5,90,h,type$,$8000$)
editbox! = window!.addEditBox(i,x,y,w,h,"",$$,type$)
if (type$ = "text") then
editbox!.setText("The quick brown fox jumps over the lazy dog.")
endif
if (type$="color") then
color$ = "#" + hta(chr(rnd(255))) + hta(chr(rnd(255))) + hta(chr(rnd(255)))
editbox!.setText(color$)
endif
if (type$="date") then
mask$ = "%Yl-%Mz-%Dz"
editbox!.setText(date(0:mask$))
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
editbox!.setAttribute("min",date(jul(0,0,0)-365:mask$))
editbox!.setAttribute("max",date(jul(0,0,0)+365:mask$))
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
endif
if (type$="datetime-local") then
mask$="%Yl-%Mz-%DzT%Hz:%mz"
editbox!.setText(date(0:mask$))
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
editbox!.setAttribute("min",date(jul(0,0,0)-365:mask$))
editbox!.setAttribute("max",date(jul(0,0,0)+365:mask$))
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
endif
if (type$="month") then
mask$="%Yl-%Mz"
editbox!.setText(date(0:mask$))
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
editbox!.setAttribute("min",date(jul(0,0,0)-365:mask$))
editbox!.setAttribute("max",date(jul(0,0,0)+365:mask$))
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
endif
if (type$="number") then
editbox!.setText(str(50))
editbox!.setAlignment(editbox!.ALIGN_RIGHT)
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
editbox!.setAttribute("min","-100")
editbox!.setAttribute("max","100")
editbox!.setAttribute("step","any")
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
endif
if (type$="range") then
editbox!.setText(str(50))
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
editbox!.setAttribute("min","-100")
editbox!.setAttribute("max","100")
print "min=",editbox!.getAttribute("min"),",max=",editbox!.getAttribute("max")
endif
if (type$="time") then
mask$="%Hz:%mz"
editbox!.setText(date(0:mask$))
endif
if (type$="week") then
mask$="%Yl-W%Wz"
editbox!.setText(date(0:mask$))
endif
editbox!.setName(type$)
editbox!.setAttribute("placeholder","placeholder text goes here")
editbox!.setToolTipText(editbox!.getEditType())
editbox!.setCallback(editbox!.ON_EDIT_MODIFY,"modify")
i = i + 1
wend
process_events
eoj:
release
getText:
control! = window!.getFocusedControl()
i = msgbox(control!.getText(err=*next),0,control!.getName(err=*next))
return
modify:
event! = sysgui!.getLastEvent()
editbox! = event!.getControl()
event$ = editbox!.getName()+" = '"+event!.getText()+"'"
status!.setText(event$)
print event$
return
|