[Bf-python] WIP: Displaying Keypresses for VideoTuts
jmsoler at free.fr
jmsoler at free.fr
Thu Nov 15 18:14:17 CET 2007
Selon Carsten Wartmann <cw at blenderbuch.de>:
> jmsoler at free.fr schrieb:
> > Selon Carsten Wartmann <cw at blenderbuch.de>:
> >
> >> jmsoler at free.fr schrieb:
> >>> I was very interested but absolutly no key had appeared.
> >>> Could you post a copy of the screen ?
> >> Did you activate the handlers in the View menu? I guess you always have
> >> "Enable Script Links" set to on in the script buttons.
> >>
> >
> > Excelent ! I love it !
>
> Thanks!
>
> The one quirk which nags me most (and prevents me from streamlining the
> scripts) is that BorderSelect while in FaceSelectMode is not working
> anymore. CircleSelect is working, BorderSelect in Edit- or ObjectMode
> also, quite strange....
>
> It is something with the Blender.Redraw(), other Redraws() (e.g. from
> Draw Module) are working with BorderSelect in FSM but then you get the
> keypress shown AFTER for example a Popup shows (I always test with
> CTRL-A)....
>
> Carsten
This is a modified version for french users.
----------------------------------------------------------------------
# SPACEHANDLER.VIEW3D.EVENT
#
# 2007 Carsten Wartmann
#
# The space handler scripts ShowKeys and DrawKeys are showing
# the actual pressed keys in the 3D View.
#
# This is usefull for presentations or video tutorials where the
# key-combinations
# will give some hints whats going on beside the narration.
#
# To use activate the handlers in the View->Space Handler Scripts memu
# The display will be for the 3DView only and need to activated for
# every
# 3DView you like to see the keypresses.
"""
Problems/Todo
* Tab and Space not showing
* some functions CTRL-Q, CTRL-W etc. not showing
* while in Transformation (GSR) the script gets no events
* B-B combination (Circle Select) not handled, maybe do the same for A-A?
"""
import Blender
from Blender import Draw
import string
try:
Blender.odo = Blender.odo + 0
except:
Blender.odo = 0
def Compose(key):
q = Blender.Window.GetKeyQualifiers()
quali = ""
if q & 3:
quali = "Maj+"
if q & 12:
quali = quali + "Alt+"
if q & 48:
quali = quali + "Ctrl+"
# english language uncomment next line
# quali = quali + "Ctrl+"
Blender.Redraw()
Blender.keypress = quali+key
Blender.odo=0
evt = Blender.event
# a-z
if (evt >= Draw.AKEY and evt <= Draw.ZKEY):
Compose(string.upper(chr(evt)))
# function keys
if (evt >= Draw.F3KEY and evt <= Draw.F11KEY):
Compose("F"+str(evt-303+4))
# number keys
if (evt >= Draw.ZEROKEY and evt <= Draw.NINEKEY):
Compose(str(evt-48))
elif evt==Draw.ESCKEY:
Compose("Echappe")
elif evt==Draw.HOMEKEY:
Compose("Home")
elif evt==Draw.TABKEY:
Compose("Tabulation")
# doesnt work... Workaround below
elif evt==Draw.SPACEKEY:
Compose("Barre espace")
# doesnt work... Workaround below
elif evt == Draw.LEFTMOUSE:
Compose("Souris : Bouton Gauche")
elif evt == Draw.MIDDLEMOUSE:
Compose("Souris : Bouton Central")
elif evt == Draw.RIGHTMOUSE:
Compose("Souris : Bouton Droit")
elif evt == Draw.WHEELUPMOUSE:
Compose("Souris : Molette avant")
elif evt == Draw.WHEELDOWNMOUSE:
Compose("Souris : Molette arriere")
# there must be a better solution, CTRL+PAD not working
# but it seems to work in french.
#----
elif evt == Draw.PAD7:
Compose("Pave Num. : 7")
elif evt == Draw.PAD1:
Compose("Pave Num. : 1")
elif evt == Draw.PAD3:
Compose("Pave Num. : 3")
elif evt == Draw.PAD5:
Compose("Pave Num. : 5")
elif evt == Draw.PADPERIOD:
Compose("Pave Num. : Point")
elif evt == Draw.PADASTERKEY:
Compose("Pave Num. : * ")
elif evt == Draw.PADMINUS:
Compose("Pave Num. : -")
elif evt == Draw.PADPLUSKEY:
Compose("Pave Num. : +")
# clear keyfield after some mouse movements
elif evt==4:
Blender.odo = Blender.odo + 1
if Blender.odo>100:
Compose("")
# some testing/debugging lines
# print dir(Draw)
# print evt
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2007: Carsten Wartmann
#
# this is a modified version for french users.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****
More information about the Bf-python
mailing list