Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify event handler docs #144

Open
BMaxV opened this issue Feb 3, 2024 · 4 comments
Open

clarify event handler docs #144

BMaxV opened this issue Feb 3, 2024 · 4 comments

Comments

@BMaxV
Copy link

BMaxV commented Feb 3, 2024

Hello, just a quick note since I'm doing something else:

I find this bit about event handlers not clear enough.

https://docs.panda3d.org/1.10/python/programming/tasks-and-events/event-handlers

"
Finally, there are some useful utility functions for debugging. The messenger typically does not print out when every event occurs. Toggling verbose mode will make the messenger print every event it receives. Toggling it again will revert it to the default. A number of methods exist for checking to see what object is checking for what event, but the print method will show who is accepting each event. Also, if accepts keep changing to the point where it is too confusing, the clear method will start the messenger over with a clear dictionary.
"

messenger.toggleVerbose()
print(messenger)
messenger.clear()

What is this messenger, how does it relate to anything, why are we using "print" and not something like .get_events().

And how do I import it? That's not in the code bit.

@ArsThaumaturgis
Copy link

ArsThaumaturgis commented Mar 9, 2024

What is this messenger

Near the top of the page to which you linked, the text "messenger.send" is clickable, and takes one to the API page for the messenger.

To quote that page:

This defines the Messenger class, which is responsible for most of the event handling that happens on the Python side.

... why are we using "print" and not something like .get_events().

I imagine that this comes down to the design philosophy of whoever coded that class. After all, it's not that uncommon for the printing of an object to prompt it to print some of the current data of that object--printing a "RenderState" object, for example, gives a brief summary of that states contained within.

And how do I import it? That's not in the code bit.

I don't think that one does: "messenger" seems to be one of the ubiquitous global variables. If you have a ShowBase object, then you should be able to access it from there. Like so:

class MyGame(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        # I'm using "print" here simply because it's a use
        #  for messenger that I have in mind right now.
        print (messenger)
        # Or
        print (self.messenger)

@BMaxV
Copy link
Author

BMaxV commented Mar 9, 2024

"messenger.send" is clickable

Wow, it is. @rdb can we change the formatting for this, because that does not read like a link to me.

I don't think that one does: "messenger" seems to be one of the ubiquitous global variables.

Yes. ...

Like so: [code]

... something like that piece of code should be in the manual, because I don't think this is obvious.

@rdb
Copy link
Member

rdb commented Mar 9, 2024

messenger is documented here:
https://docs.panda3d.org/1.10/python/reference/builtins#builtins.messenger

We could add an explanation of the global to the API reference page of the Messenger class.

@ArsThaumaturgis
Copy link

We could add an explanation of the global to the API reference page of the Messenger class.

It could be as simple as linking to the page to which you just linked. Something like:
"The default instance of this class is one of the many globals provided by the ShowBase class"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants