BUI logoDWC logoBBjControl::getAttribute

Description

In BBj 15.00 and higher, this method returns a control attribute for the BBjControl previously set with BBjControl::setAttribute.

Syntax

Return Value

Method

string getAttribute(String attribute)

Parameters

Parameter Description
attribute Specifies an attribute to be retrieved from the control.

Return Value

Returns the text that value of this attribute.

Remarks

This functionality is primarily intended for setting low-level BUI element attributes or DWC component attributes. When running in GUI, the attributes don't affect the control itself, but may be used by the developer.

Example

rem ' BBjControl::getAttribute 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

See Also

BBjAPI

BBjSysGui

BBjWindow

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.