I’ve arranged several horizontal DirectSlider objects in a vertical column so that they don’t overlap. It looks a bit like the following:
Visually, these sliders are independent, but when I click in the paging range of the top one, I move the slider on the middle one.
What is the click detection range for a DirectSlider, and is there a way for me to show it visually? I expected it to be the paging range, but the click detection range for paging seems to exceed the visual bounds set by frameSize.
base.mouseWatcherNode.showRegions(render2d, 'gui-popup', 0)
to reveal the click regions of all your DirectGui objects.
Excellent; that’s exactly what we wanted to see!
Executing base.mouseWatcherNode.showRegions(render2d) shows all the clickable regions on our interface. As we’d suspected, the clickable region on each slider’s paging region is blown far outside the slider’s frameSize bounds so that it’s overlapping the sliders above and below it.
Is there a way to directly control the clickable region for the paging region? We’d like to tighten it up so that it has a simple 1:1 correspondence with the frameSize of the DirectSlider itself.
Hmm, in my quick experiments (creating a DirectSlider with the default parameters), it appears that the clickable region exactly matches the frameSize.
What are the parameters you are using to create your DirectSlider?
I have to apologize for being out of touch for so long; it’s been a pretty busy weekend here, and I wasn’t able to get around to investigating the questions I’d asked in more detail until this week. All of my tests operated on a horizontal slider in Panda3D 1.2.3.
First of all, I understand now why the visible (gray bar) section of the slider wasn’t lining up with the clickable (height of slider) region. There exists an undocumented property ‘frameVisibleScale’ that DirectSlider uses to cause the visible frame to be less than the clickable frameSize. We had thought that the visible bar was at frameSize (i.e. the slider was larger than frameSize), so we hadn’t realized that scaling up to a size where the visible bar was where we wanted it had made the clickable region much larger. I’ve updated the Panda3D manual with documentation of this property.
There also exists another unexpected behavior: It appears that frameSize is treated as both an initialization property (in that it sets some aspects that are subsequently immutable) and a modifiable property. The position of the thumb relative to the center of the slider’s frame is determined by the original frame size: For a frame of (-1,1,-1,1), the slider is centered on the frame, but for a frame of (-1,1,0,1), the slider is centered at the bottom of the frame. This is perfectly fine; the confusion occurs when one changes the frameSize subequently, which then changes the slider’s position. It’s an understandable behavior, but we had anticipated that the thumb would always stay in the center of the frame; we do a lot of our DirectGUI manipulation purely through setting frameSize and often leave the object’s position alone, to simplify the number of variables that must be manipulated to control a GUI component’s onscreen behavior.
I think we now have a much better grasp of the DirectSliders. As always, thank you for all the help, and for that very useful debugging command!