Input events are messages about input from the keyboard or from the mouse.
GeUserArea.InputEvent()
if the user area is in focus. They can also be intercepted in
GeDialog.Message()
.
Further, any code can either poll the event queue with
GetInputEvent()
or get the current input state with
GetInputState()
.
Input events are stored in
BaseContainer
objects. The ID of the container is
BFM_INPUT
(this is also the ID to look for in
GeDialog.Message()
). The content of the container is:
Container ID Type Description
BFM_INPUT_QUALIFIER
LONGA bitmask with the qualifiers at the time when the event occurred.
QSHIFTShift.
QCTRLControl.
QALTAlt.
QALT2Alt Gr.
BFM_INPUT_MODIFIERS
LONGSame as
BFM_INPUT_QUALIFIERbut also contains bits > 0xf. Private.
BFM_INPUT_DEVICE
LONGDevice. One of the following types:
BFM_INPUT_MOUSEMouse.
BFM_INPUT_KEYBOARDKeyboard.
BFM_INPUT_ASC
StringContains the unicode-text.
BFM_INPUT_CHANNEL
LONGThe channel contains the key or button ('A' means A, KEY_F1 means F1):
BFM_INPUT_MOUSELEFTLeft mouse button.
BFM_INPUT_MOUSERIGHTRight mouse button.
BFM_INPUT_MOUSEMIDDLEMiddle mouse button.
BFM_INPUT_MOUSEX1Fourth mouse button.
BFM_INPUT_MOUSEX2Five mouse button.
BFM_INPUT_MOUSEWHEELMouse wheel message.
BFM_INPUT_VALUE
LONGChannel value flag. Normally
TrueorFalse. The actual value can be found inBF_INPUT_VALUE_REAL.
BFM_INPUT_VALUE_REAL
RealChannel value (e.g. pressure) as a float.
BFM_INPUT_X
LONGX value.
BFM_INPUT_Y
LONGY value.
BFM_INPUT_Z
LONGZ value.
BFM_INPUT_TILT
LONGPen tilt.
BFM_INPUT_ORIENTATION
RealPen rotation.
BFM_INPUT_FINGERWHEEL
LONGFinger wheel.
BFM_INPUT_P_ROTATION
RealPen rotation around its own axis.
BFM_INPUT_DOUBLECLICK
BoolDouble click.
BFM_ACTION_ID
LONGContains the ID of the dialog element that triggered the action.
BFM_ACTION_VALUE
ANYAction value.
BFM_ACTION_INDRAG
BoolSlider in dragging mode (not finished).
BFM_ACTION_STRCHG
BoolString in Textfield changed.
BFM_ACTION_VALCHG
BoolNumberEdit/SliderChg.
BFM_ACTION_ESC
BoolAction escaped.
BFM_ACTION_RESET
BoolAction escaped.
BFM_ACTION_UPDATE
BoolUpdate without verify.
BFM_ACTIVE
BoolFlag, if window is active.
BFM_DRAW_LEFT
LONGLeft clipping.
BFM_DRAW_TOP
LONGTop clipping.
BFM_DRAW_RIGHT
LONGRight clipping.
BFM_DRAW_BOTTOM
LONGBottom clipping.
BFM_DRAW_HASRECT
BoolFlag for a existing redraw rectangle.
BFM_DRAW_REASON
BaseContainerMessage which started the redraw.
BFM_DRAW_OGL
BoolOpenGL flag.
RESULT_CURSOR
LONGCursortype:
MOUSE_HIDEHide cursor.
MOUSE_SHOWShow cursor.
MOUSE_NORMALNormal cursor.
MOUSE_BUSYBusy cursor.
MOUSE_CROSSCross cursor.
MOUSE_QUESTIONQuestion cursor.
MOUSE_ZOOM_INZoom in cursor.
MOUSE_ZOOM_OUTZoom out cursor.
MOUSE_FORBIDDENForbidden cursor.
MOUSE_DELETEDelete cursor.
MOUSE_COPYCopy cursor.
MOUSE_INSERTCOPYInsert copy cursor.
MOUSE_INSERTCOPYDOWNInsert copy down cursor.
MOUSE_MOVEMove cursor.
MOUSE_INSERTMOVEInsert move cursor.
MOUSE_INSERTMOVEDOWNInsert move down cursor.
MOUSE_ARROW_HHorizontal arrow cursor.
MOUSE_ARROW_VVertical arrow cursor.
MOUSE_ARROW_HVHorizontal and vertical arrow cursor.
MOUSE_POINT_HANDPoint hand cursor.
MOUSE_MOVE_HANDMove hand cursor.
MOUSE_IBEAMI-beam cursor.
MOUSE_SELECT_LIVELive selection cursor.
MOUSE_SELECT_FREEFree selection cursor.
MOUSE_SELECT_RECTRectangle selection cursor.
MOUSE_SELECT_POLYPolygon selection cursor.
MOUSE_SPLINETOOLSSpline tools cursor.
MOUSE_EXTRUDEExtrude cursor.
MOUSE_NORMALMOVENormal move cursor.
MOUSE_ADDPOINTSAdd points cursor.
MOUSE_ADDPOLYGONSAdd polygons cursor.
MOUSE_BRIDGEBridge cursor.
MOUSE_MIRRORMirror cursor.
MOUSE_PAINTMOVEPaint move cursor.
MOUSE_PAINTSELECTRECTPaint select rectangle cursor.
MOUSE_PAINTSELECTCIRCLEPaint select circle cursor.
MOUSE_PAINTSELECTPOLYPaint select polygon cursor.
MOUSE_PAINTSELECTFREEPaint select free cursor.
MOUSE_PAINTMAGICWANDPaint magic wand cursor.
MOUSE_PAINTCOLORRANGEPaint color range cursor.
MOUSE_PAINTFILLPaint fill cursor.
MOUSE_PAINTPICKPaint pick cursor.
MOUSE_PAINTBRUSHPaint brush cursor.
MOUSE_PAINTCLONEPaint clone cursor.
MOUSE_PAINTTEXTPaint text cursor.
MOUSE_PAINTCROPPaint crop cursor.
MOUSE_PAINTLINEPaint line cursor.
MOUSE_PAINTPOLYSHAPEPaint polygon shape cursor.
RESULT_HELP1
StringHelp 1.
RESULT_HELP2
StringHelp 2.
RESULT_HELP3
StringHelp 3.
RESULT_HELP4
StringHelp 4.
RESULT_BUBBLEHELP
StringBubblehelp text.
RESULT_SUPPRESSBUBBLE
BoolSuppress bubble help.
RESULT_BUBBLEHELP_TITLE
StringBubble help text title. Printed in bold for the bubblehelp, not visible in the statusbar.
Note
The values for
BFM_INPUT_DEVICE
and
BFM_INPUT_CHANNEL
are used with
GetInputState()
and
GetInputEvent()
to get specific events only.
There are no events for things like mouse-up or mouse-leave in Cinema 4D. The reason is that there is no reliable way to get such messages that is completely portable. Therefore it is sometimes necessary to enter a manual while loop that ends when the mouse is released. For example, to track how the user drags something with the left button down one would do:
state = c4d.BaseContainer() while gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, state): if state.GetInt32(c4d.BFM_INPUT_VALUE)==0: break x = state.GetInt32(c4d.BFM_INPUT_X) y = state.GetInt32(c4d.BFM_INPUT_Y) #x, y
Note
Needless to say, try not to get caught in any infinite loops during such polls! If sending BFM_ACTION messages, for example fom a custom slider control, set the BFM_ACTION_INDRAG flag to True in those messages while in the loop.