IntroductionInstallationLimitations of the "file" protocolFrequently asked questionsSyntax, keywords and built-in functionsStandard distributionimport implementationBrython packagesBrowser interface
Introduction - DOM API
Creating a document Accessing elements Attributes, properties and methods Events Mouse events Keyboard events Focus events Drag events Query string Interactions with Javascript Brython-specific built-in modules
browser
browser.aio browser.ajax browser.html browser.local_storage browser.markdown browser.object_storage browser.session_storage browser.svg browser.template browser.timer browser.webcomponent browser.websocket browser.worker Widgets browser.widgets.dialog browser.widgets.menu interpreter javascript Working with BrythonCookbook |
Mouse eventsThe mouse-related events (movement, pressing a button) are
Examplesmouseenter and mouseleavethese events are triggered when the mouse enters or leaves an element. If an element includes other ones, the event is triggered every time the mouse enters or leaves a child element
the difference with mouseenter and mouseleave is that once the mouse entered an element, the event is not triggered on its children elements
For mouse events, the instance of |
button | indicates which button was pressed on the mouse to trigger the event |
buttons | indicates which buttons were pressed on the mouse to trigger the event. Each button that can be pressed is represented by a given number (1 : Left button, 2 : Right button, 4 : Wheel button). If more than one button is pressed, the value of the buttons is combined to produce a new number. For example, if the right button (2) and the wheel button (4) are pressed, the value is equal to 2|4, which is 6 |
x | position of the mouse relatively to the left border of the window (in pixels) |
y | position of the mouse relatively to the upper border of the window (in pixels) |
clientX | the X coordinate of the mouse pointer in local (DOM content) coordinates |
clientY | the Y coordinate of the mouse pointer in local (DOM content) coordinates |
screenX | the X coordinate of the mouse pointer in global (screen) coordinates |
screenY | the Y coordinate of the mouse pointer in global (screen) coordinates |
svgX, svgY | the X, Y coordinates of the mouse pointer, relatively to the upper left corner of the SVG element |