Popover is very useful on showing additional info or displaying instructions especially when the control is click or hovered.
These are the setter and getter properties for the showPopover Component.
Example - Positioning
class Main extends App
{
onStart()
{
this.main = ui.addLayout( "main", "Linear", "VCenter,Horizontal", 1, 1 )
var lay1 = ui.addLayout( this.main, "Linear", "VCenter", 0.5, 1 )
lay1.setChildMargins(0, 0.05)
ui.addText(lay1, "Position on parent", "h5")
var btn = ui.addButton(lay1, "Top-Left")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,tl") } )
btn = ui.addButton(lay1, "Top-Center")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tc,tl") } )
btn = ui.addButton(lay1, "Top-Right")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tr,tl") } )
btn = ui.addButton(lay1, "Center-Left")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "cl,tl") } )
btn = ui.addButton(lay1, "Center-Center")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "cc,tl") } )
btn = ui.addButton(lay1, "Center-Right")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "cr,tl") } )
btn = ui.addButton(lay1, "Bottom-Left")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "bl,tl") } )
btn = ui.addButton(lay1, "Bottom-Center")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "bc,tl") } )
btn = ui.addButton(lay1, "Bottom-Right")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "br,tl") } )
var lay2 = ui.addLayout( this.main, "Linear", "VCenter", 0.5, 1 )
lay2.setChildMargins(0, 0.05)
ui.addText(lay2, "Origin on popover", "h5")
btn = ui.addButton(lay2, "Top-Left")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,tl") } )
btn = ui.addButton(lay2, "Top-Center")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,tc") } )
btn = ui.addButton(lay2, "Top-Right")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,tr") } )
btn = ui.addButton(lay2, "Center-Left")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl", "cl") } )
btn = ui.addButton(lay2, "Center-Center")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,cc") } )
btn = ui.addButton(lay2, "Center-Right")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,cr") } )
btn = ui.addButton(lay2, "Bottom-Left")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,bl") } )
btn = ui.addButton(lay2, "Bottom-Center")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,bc") } )
btn = ui.addButton(lay2, "Bottom-Right")
btn.setOnTouch( function() { ui.showPopover(this, "This is a popover message", "tl,br") } )
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "VCenter,Horizontal", 1, 1)
lay1 = ui.addLayout(main, "Linear", "VCenter", 0.5, 1)
lay1.setChildMargins(0, 0.05)
ui.addText(lay1, "Position on parent", "h5")
btn = ui.addButton(lay1, "Top-Left")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,tl"))
btn = ui.addButton(lay1, "Top-Center")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tc,tl"))
btn = ui.addButton(lay1, "Top-Right")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tr,tl"))
btn = ui.addButton(lay1, "Center-Left")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "cl,tl"))
btn = ui.addButton(lay1, "Center-Center")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "cc,tl"))
btn = ui.addButton(lay1, "Center-Right")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "cr,tl"))
btn = ui.addButton(lay1, "Bottom-Left")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "bl,tl"))
btn = ui.addButton(lay1, "Bottom-Center")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "bc,tl"))
btn = ui.addButton(lay1, "Bottom-Right")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "br,tl"))
lay2 = ui.addLayout(main, "Linear", "VCenter", 0.5, 1)
lay2.setChildMargins(0, 0.05)
ui.addText(lay2, "Origin on popover", "h5")
btn = ui.addButton(lay2, "Top-Left")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,tl"))
btn = ui.addButton(lay2, "Top-Center")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,tc"))
btn = ui.addButton(lay2, "Top-Right")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,tr"))
btn = ui.addButton(lay2, "Center-Left")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl", "cl"))
btn = ui.addButton(lay2, "Center-Center")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,cc"))
btn = ui.addButton(lay2, "Center-Right")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,cr"))
btn = ui.addButton(lay2, "Bottom-Left")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,bl"))
btn = ui.addButton(lay2, "Bottom-Center")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,bc"))
btn = ui.addButton(lay2, "Bottom-Right")
btn.setOnTouch(lambda event: ui.showPopover("This is a popover message", "tl,br"))
Example - Advanced
class Main extends App
{
onStart()
{
this.main = ui.addLayout( "main", "Linear", "VCenter", 1, 1 )
this.btn = ui.addButton( this.main, "Show Popover" )
this.btn.setOnTouch( this.onTouch )
}
onTouch() {
var lay = ui.addLayout(null, "Linear", "VCenter,Left")
lay.setChildMargins(0.1, 0.05, 0.1, 0.05)
ui.addText(lay, "Header", "h5")
ui.addText(lay, "This is a very long text to display in this popover", "Left")
ui.addButton(lay, "Outlined Button", "Outlined", "Secondary")
ui.showPopover( this.btn, lay, "bl,tr")
}
}
from hybrid import ui
def OnStart():
global btn
main = ui.addLayout("main", "Linear", "VCenter", 1, 1)
btn = ui.addButton(main, "Show Popover")
btn.setOnTouch(onTouch)
def onTouch(event):
lay = ui.addLayout(None, "Linear", "VCenter,Left")
lay.setChildMargins(0.1, 0.05, 0.1, 0.05)
ui.addText(lay, "Header", "h5")
ui.addText(lay, "This is a very long text to display in this popover", "Left")
ui.addButton(lay, "Outlined Button", "Outlined", "Secondary")
ui.showPopover(btn, lay, "bl,tr")