panda3d-docs icon indicating copy to clipboard operation
panda3d-docs copied to clipboard

suggested changes for mouse position how to from discord

Open BMaxV opened this issue 1 year ago • 0 comments

https://discord.com/channels/524691714909274162/1057767450843824198/1211462257725145150

12:54 AM]Simulan:
                # get mouse data
                mouse_watch = base.mouseWatcherNode
                if mouse_watch.has_mouse():
                    pointer = base.win.get_pointer(0)
                    mouseX = pointer.get_x()
                    mouseY = pointer.get_y()

...is how I've been doing it for FPS
[12:57 AM]rdb: Er, you're mixing interfaces
[12:58 AM]rdb: Instead of checking has_mouse(), check pointer.in_window
[12:58 AM]rdb: Your code may occasionally behave erratically in some edge cases
[12:59 AM]Simulan: Hmm okay I'll check it out later
[1:07 AM]Simulan: So I suppose that should be:

                # get mouse data
                pointer = base.win.get_pointer(0)
                if pointer.in_window:
                    mouseX = pointer.get_x()
                    mouseY = pointer.get_y()

BMaxV avatar Feb 26 '24 08:02 BMaxV