Perfectly clear, indeed.
However, it doesn’t work as we expected.
When yo do that, the 3d view behaves as expected, but now… if you put a button in the right part of the screen, do you guess where do you have to click to select it? Yes, in the rightmost part of the 3d-view.
After a number of tests (by example, i created 2 non-overlapping MouseSubregions, but i was limited to put GUI’s controls on one and/or the other zones, but not crossing the frontier between both), i have come to the conclusion that this is the most reasonable choice:
mk = base.dataRoot.attachNewNode(MouseAndKeyboard(self.win, i, name))
mw = mk.attachNewNode(MouseWatcher(name))
msr = mw.attachNewNode(MouseSubregion(name))
mw2 = msr.attachNewNode(MouseWatcher("sec"))
bt = mw2.attachNewNode(ButtonThrower(name))
mods = ModifierButtons()
as you can see, i’m using two MouseWatcher; the first one is there to contain the GUI’s control (i have decided to drop aspect2d, as i want the controls stretch over all the right zone):
self.render2dPG = self.render2d.attachNewNode(PGTop("render2dPG"))
The second one, to receive mouse events in the 3d-view (normalized to [-1,1]*[-1,1]):
self.mouseWatcher = self.buttonThrowers.getParent()
self.mouseWatcherNode = self.mouseWatcher.node()
mpos = self.mouseWatcherNode.getMouse()
print mpos.getX(), mpos.getY()
Of course, i have to touch the camera in a similar way:
Now i can add some control to the right zone:
testButton = DirectButton(text = "Extended length\nbutton text", text_pos=(0.8,0.92), text_scale=(0.05,0.05), frameSize=(0.6,1,0.8,1), relief = DGG.RAISED, borderWidth=(0.01,0.01), pressEffect = 1, command=self.buttonPressed)
and… all the mouse events work fine. (The button can be pressed, the pieces in the 3d view can be selected when adding collision logic, etc)
And now… the questions’ turn
First, i have seen that i can drop away the line
self.drive = self.mouseWatcher.attachNewNode(DriveInterface('drive'))
Which was the utility of that? Do i need it?
Second, when opening a new window… can i ask that the aspect rate be maintained when the user manually resize the window? (Of course, i would still let the user can maximize the window)
Now, please take a look at this image:
I have a couple of questions…
first, what is the gray zone in the upper-left corner. Is it the limit of an environment attached to render? I firstly supposed it was due to the camera having a small “far distance” property, but it doesn’t seem to be the case, as i have used camera2.node().getLens().setFar with a big value as parameters, and it doesn’t change anything.
The other is… well, with certain sizes of the window, the text of the button can be seen fine, but at others it gets blurred. Of course, i understand there is a limit on what you can expect when scaling the text, but i was wondering if there is any option i should know to make the text “sharper” and avoid (as long as it be possible) the blurring.
Well, sure i have had more doubts, but that’s all i remember now.