GetBounds for DirectScrolledList requires step

I could not figure out why DirectScrolledList.getBounds() would always return 0. I did some experiments in the terminal and found that taskMgr needs to do a step for getBounds to return a non zero result. This a bug or needed behavior when adding items.

Second question, is it safe to call taskMgr.step() while in the run() loop?
edit - Nope, it isn’t :frowning:

Perhaps it will work if you call refresh() before calling getBounds()?

David

Just tried. Still returned 0s until i did a step.

Hmm, I just tried it with the example DirectScrolledList constructor that appears at the bottom of DirectScrolledList.py, and it appears to work fine–it returns the same nonzero result from getBounds() immediately after construction that it returns on all subsequent frames.

Can you post an example of your DirectScrolledList constructor in which this doesn’t work?

David

Right from the manual:

from direct.directbase import DirectStart
from direct.gui.DirectGui import *
from pandac.PandaModules import *
 
b1 = DirectButton(text = ("Button1", "click!", "roll", "disabled"),
                  text_scale=0.1, borderWidth = (0.01, 0.01),
                  relief=2)
 
b2 = DirectButton(text = ("Button2", "click!", "roll", "disabled"),
                  text_scale=0.1, borderWidth = (0.01, 0.01),
                  relief=2)
 
numItemsVisible = 4
itemHeight = 0.11
 
myScrolledList = DirectScrolledList(
    decButton_pos= (0.35, 0, 0.53),
    decButton_text = "Dec",
    decButton_text_scale = 0.04,
    decButton_borderWidth = (0.005, 0.005),
 
    incButton_pos= (0.35, 0, -0.02),
    incButton_text = "Inc",
    incButton_text_scale = 0.04,
    incButton_borderWidth = (0.005, 0.005),
 
    frameSize = (0.0, 0.7, -0.05, 0.59),
    frameColor = (1,0,0,0.5),
    pos = (-1, 0, 0),
    items = [b1, b2],
    numItemsVisible = numItemsVisible,
    forceHeight = itemHeight,
    itemFrame_frameSize = (-0.2, 0.2, -0.37, 0.11),
    itemFrame_pos = (0.35, 0, 0.4),
    )


print myScrolledList.getBounds()

taskMgr.step()

print myScrolledList.getBounds()

Ah, try calling myScrolledList.updateFrameStyle().

David

Perfect!