B4J Tutorial [BANanoWebix] Show a progressbar on long processes

Ola

Download BANanoWebix


Based on a request I received, the WixProgressBar comes handy for showing long processes. You just run the .SetProgressBar(elementID, config) and it will show a progressbar anytime you want to show it.

ProgressBar.gif


WixProgressBar
  • Item As Map
    return the item
  • SetType (sType As Object) As WixProgressBar
    set type - top,bottom,icon
  • SetTypeTop (typeTop As Object) As WixProgressBar 'ignore
    draw a bar above the view/application
  • SetTypeBottom (typeBottom As Object) As WixProgressBar 'ignore
    draws a bar below a view/application
  • SetTypeIcon (typeIcon As Object) As WixProgressBar 'ignore
    draw an icon in the middle of a view/application
  • SetIcon (icon As Object) As WixProgressBar
    icon name to display from font awesome
  • SetDelay (delay As Int) As WixProgressBar
    life time in milliseconds of the progress bar, after which it is hidden (if hide parameter is enabled)
  • SetHide (hide As Boolean) As WixProgressBar
    specifies whether a progress bar/icon should be hidden after its life time
  • SetPosition (position As Double) As WixProgressBar
    an optional parameter, true only for the progress bar. Specifies the position of a progress mark on a bar. Varies from 0 to 1.
Usage of the class.

B4X:
Dim pbx As WixProgressBar
    pbx.Initialize("").SetTypeIcon("").SetDelay(500).SetHide(True)
    pg.SetProgressBar("propbag", pbx)

We want to show a progress bar for 500 milliseconds and hide it and it should be placed at the center of the "progbar"

Ta!
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
You can show the progress bar indefinately by leaving the delay and hide options out. Doing that will mean you will unset it off yourself. You can unset it by executing

.UnsetProgressBar("propbar") in this example.

Internally these functions are...

B4X:
'set a progress bar to an element
Sub SetProgressBar(eid As String, pbdef As WixProgressBar)
    eid = eid.tolowercase
    Dim pb As BANanoObject = webix.GetField("ProgressBar")
    Dim itm As BANanoObject = Dollar.Selector(eid)
    webix.RunMethod("extend", Array(itm, pb))'
    itm.RunMethod("showProgress", pbdef.Item)
End Sub

'unset the progress bar
Sub UnsetProgressBar(eid As String)
    eid = eid.ToLowerCase
    Dollar.Selector(eid).RunMethod("hideProgress",Null)
End Sub
 
Top