== Python Space Handlers ==

- Old feature request: now space handlers can report release events, too. For that a new space handler type was added, here's the header for it:

# SPACEHANDLER.VIEW3D.EVENT.ALL

These scripts report both "presses and releases". For release events, Blender.eventValue is zero and Blender.link == Blender.SpaceHandlers.VIEW3D_EVENT_RELEASE. Check the API_related bpy doc for more info.

- Bug fix: left mouse clicks could be reported twice.

Important: for both the feature and the fix, to make the code nicer and to let space handlers become available in more situations, I moved the check for space handlers in space.c. Now it happens before checks for grease pencil, sculpt and left/right mouse button swapping. If this causes any problem (it shouldn't), please report.

PS: Thanks to Steven Truppe, who asked for this and even sent me a patch, but to preserve compatibility with existing event space handler scripts I did things in a different way.
This commit is contained in:
2008-12-09 00:18:30 +00:00
parent 2746034295
commit caf58fe4b2
6 changed files with 73 additions and 38 deletions

View File

@@ -184,11 +184,11 @@ Introduction:
Space Handler script links:
---------------------------
This is a new kind of script linked to spaces in a given window. Right now
only the 3D View has the necessary hooks, but the plan is to add access to
other types, too. Just to clarify naming conventions: in Blender, a screen
is partitioned in windows (also called areas) and each window can show any
space. Spaces are: 3D View, Text Editor, Scripts, Buttons, User Preferences,
These are scripts linked to spaces in a given window. Right now
only the 3D View has the necessary hooks. Just to clarify naming
conventions: in Blender, a screen is partitioned in windows (also
called areas) and each window can show any space.
Spaces are: 3D View, Text Editor, Scripts, Buttons, User Preferences,
Oops, etc.
Space handlers are texts in the Text Editor, like other script links, but they
@@ -196,12 +196,16 @@ Introduction:
text file}} must inform:
1. that they are space handlers;
2. the space they belong to;
3. whether they are EVENT or DRAW handlers.
3. whether they are EVENT, EVENT_RELEASE (EVENT ones reporting key release events) or DRAW handlers.
Example header for a 3D View EVENT handler::
# SPACEHANDLER.VIEW3D.EVENT
Example header for a 3D View EVENT handler that also receives release events::
# SPACEHANDLER.VIEW3D.EVENT.ALL
Example header for a 3D View DRAW handler::
# SPACEHANDLER.VIEW3D.DRAW
@@ -216,6 +220,10 @@ Introduction:
- process it (the script must set Blender.event to None then);
- ignore it.
EVENT ALL space handlers (header: # SPACEHANDLER.VIEW3D.EVENT.ALL) are executed
both for key presses (Blender.event = Blender.SpaceHandlers.VIEW3D_EVENT) and
for key releases (Blender.event = Blender.SpaceHandlers.VIEW3D_EVENT_RELEASE).
Setting C{Blender.event = None} tells Blender not to go on processing itself
the event, because it was grabbed by the script.
@@ -248,7 +256,7 @@ Introduction:
- B{bylink} is the same: True if the script is running as a script link;
- B{link}: integer from the L{Blender}.SpaceHandlers constant dictionary,
tells what space this handler belongs to and the handler's type
(EVENT, DRAW);
(EVENT, EVENT_RELEASE, DRAW);
- B{event}:
- EVENT handlers: an input event (check keys and mouse events in
L{Draw}) to be processed or ignored;
@@ -258,6 +266,7 @@ Introduction:
presses (since we don't pass releases) as 1 and mouse movements
(Draw.MOUSE.X and Draw.MOUSE.Y) as the current x or y coordinate,
for example;
- EVENT_RELEASE handlers (EVENT handlers executed during key release events): 0;
- DRAW handlers: 0 always.
B{Guidelines (important)}: