From 58c91b941be551e47fea1d54c860ceef9d78ec35 Mon Sep 17 00:00:00 2001 From: "Nicholas H.Tollervey" Date: Thu, 24 Oct 2024 14:54:13 +0100 Subject: [PATCH] Docstrings --- core/src/stdlib/pyscript/event_handling.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/src/stdlib/pyscript/event_handling.py b/core/src/stdlib/pyscript/event_handling.py index 39713416..a52181ee 100644 --- a/core/src/stdlib/pyscript/event_handling.py +++ b/core/src/stdlib/pyscript/event_handling.py @@ -14,13 +14,16 @@ from pyscript.magic_js import document def when(target, *args, **kwargs): """ + A decorator and function for attaching event handlers to DOM elements or + whenable objects. + When used as a decorator, the target is the object that will trigger the + event. The handler function is the decorated function. The handler function + will be called when the target is triggered. - unwhen(whenable, handler) - - disconnect(whenable, handler) - - + When used as a function, the target is the object that will trigger the + event. The handler function is the next argument. The remaining arguments + and keyword arguments are passed to the target when it is triggered. """ # If "when" is called as a function, try to grab the handler from the # arguments. If there's no handler, this must be a decorator based call.