Input Events

Input events are messages about input from the keyboard or from the mouse.

Distribution

All input events are stored in a central queue. The events are automatically sent to GeDialog.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().

Structure

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()). This is the contents of the container:

Container ID Type Description

BFM_INPUT_QUALIFIER

LONG

A bitmask with the qualifiers at the time when the event occured.

QSHIFT

Shift.

QCTRL

Control.

QALT

Alt.

QALT2

Alt Gr.

BFM_INPUT_MODIFIERS

LONG

Same as BFM_INPUT_QUALIFIER but also contains bits > 0xf. Private.

BFM_INPUT_DEVICE

LONG

Device. One of the following types:

BFM_INPUT_MOUSE

Mouse.

BFM_INPUT_KEYBOARD

Keyboard.

BFM_INPUT_ASC

String

Contains the unicode-text.

BFM_INPUT_CHANNEL

LONG

The channel contains the key or button ('A' means A, KEY_F1 means F1):

BFM_INPUT_MOUSELEFT

Left mouse button.

BFM_INPUT_MOUSERIGHT

Right mouse button.

BFM_INPUT_MOUSEMIDDLE

Middle mouse button.

BFM_INPUT_MOUSEX1

Fourth mouse button.

BFM_INPUT_MOUSEX2

Five mouse button.

BFM_INPUT_MOUSEWHEEL

Mouse wheel message.

BFM_INPUT_VALUE

LONG

Channel value flag. Normally True or False. The actual value can be found in BF_INPUT_VALUE_REAL.

BFM_INPUT_VALUE_REAL

Real

Channel value (e.g. pressure) as a float.

BFM_INPUT_X

LONG

X value.

BFM_INPUT_Y

LONG

Y value.

BFM_INPUT_Z

LONG

Z value.

BFM_INPUT_TILT

LONG

Pen tilt.

BFM_INPUT_ORIENTATION

Real

Pen rotation.

BFM_INPUT_FINGERWHEEL

LONG

Finger wheel.

BFM_INPUT_P_ROTATION

Real

Pen rotation around its own axis.

BFM_INPUT_DOUBLECLICK

Bool

Double click.

BFM_ACTION_ID

LONG

Contains the ID of the dialog element that triggered the action.

BFM_ACTION_VALUE

ANY

Action value.

BFM_ACTION_INDRAG

Bool

Slider in dragging mode (not finished).

BFM_ACTION_STRCHG

Bool

String in Textfield changed.

BFM_ACTION_VALCHG

Bool

NumberEdit/SliderChg.

BFM_ACTION_ESC

Bool

Action escaped.

BFM_ACTION_RESET

Bool

Action escaped.

BFM_ACTION_UPDATE

Bool

Update without verify.

BFM_ACTIVE

Bool

Flag, if window is active.

BFM_DRAW_LEFT

LONG

Left clipping.

BFM_DRAW_TOP

LONG

Top clipping.

BFM_DRAW_RIGHT

LONG

Right clipping.

BFM_DRAW_BOTTOM

LONG

Bottom clipping.

BFM_DRAW_HASRECT

Bool

Flag for a existing redraw rectangle.

BFM_DRAW_REASON

BaseContainer

Message which started the redraw.

BFM_DRAW_OGL

Bool

OpenGL flag.

RESULT_CURSOR

LONG

Cursortype:

MOUSE_HIDE

Hide cursor.

MOUSE_SHOW

Show cursor.

MOUSE_NORMAL

Normal cursor.

MOUSE_BUSY

Busy cursor.

MOUSE_CROSS

Cross cursor.

MOUSE_QUESTION

Question cursor.

MOUSE_ZOOM_IN

Zoom in cursor.

MOUSE_ZOOM_OUT

Zoom out cursor.

MOUSE_FORBIDDEN

Forbidden cursor.

MOUSE_DELETE

Delete cursor.

MOUSE_COPY

Copy cursor.

MOUSE_INSERTCOPY

Insert copy cursor.

MOUSE_INSERTCOPYDOWN

Insert copy down cursor.

MOUSE_MOVE

Move cursor.

MOUSE_INSERTMOVE

Insert move cursor.

MOUSE_INSERTMOVEDOWN

Insert move down cursor.

MOUSE_ARROW_H

Horizontal arrow cursor.

MOUSE_ARROW_V

Vertical arrow cursor.

MOUSE_ARROW_HV

Horizontal and vertical arrow cursor.

MOUSE_POINT_HAND

Point hand cursor.

MOUSE_MOVE_HAND

Move hand cursor.

MOUSE_IBEAM

I-beam cursor.

MOUSE_SELECT_LIVE

Live selection cursor.

MOUSE_SELECT_FREE

Free selection cursor.

MOUSE_SELECT_RECT

Rectangle selection cursor.

MOUSE_SELECT_POLY

Polygon selection cursor.

MOUSE_SPLINETOOLS

Spline tools cursor.

MOUSE_EXTRUDE

Extrude cursor.

MOUSE_NORMALMOVE

Normal move cursor.

MOUSE_ADDPOINTS

Add points cursor.

MOUSE_ADDPOLYGONS

Add polygons cursor.

MOUSE_BRIDGE

Bridge cursor.

MOUSE_MIRROR

Mirror cursor.

MOUSE_PAINTMOVE

Paint move cursor.

MOUSE_PAINTSELECTRECT

Paint select rectangle cursor.

MOUSE_PAINTSELECTCIRCLE

Paint select circle cursor.

MOUSE_PAINTSELECTPOLY

Paint select polygon cursor.

MOUSE_PAINTSELECTFREE

Paint select free cursor.

MOUSE_PAINTMAGICWAND

Paint magic wand cursor.

MOUSE_PAINTCOLORRANGE

Paint color range cursor.

MOUSE_PAINTFILL

Paint fill cursor.

MOUSE_PAINTPICK

Paint pick cursor.

MOUSE_PAINTBRUSH

Paint brush cursor.

MOUSE_PAINTCLONE

Paint clone cursor.

MOUSE_PAINTTEXT

Paint text cursor.

MOUSE_PAINTCROP

Paint crop cursor.

MOUSE_PAINTLINE

Paint line cursor.

MOUSE_PAINTPOLYSHAPE

Paint polygon shape cursor.

RESULT_HELP1

String

Help 1.

RESULT_HELP2

String

Help 2.

RESULT_HELP3

String

Help 3.

RESULT_HELP4

String

Help 4.

RESULT_BUBBLEHELP

String

Bubblehelp text.

RESULT_SUPPRESSBUBBLE

Bool

Suppress bubble help.

The values for BFM_INPUT_DEVICE and BFM_INPUT_CHANNEL are used with GetInputState() and GetInputEvent() to get specific events only.

Continuous polling

There are no events for things like mouse-up or mouse-leave in C4D. 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 you would do:

state=c4d.BaseContainer()
while gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, state):
    if state.GetLong(c4d.BFM_INPUT_VALUE)==0: break

    x=state.GetLong(BFM_INPUT_X)
    y=state.GetLong(BFM_INPUT_Y)

    #x, y

Note

Needless to say, try not to get caught in any infinite loops during such polls! If you’re sending BFM_ACTION messages, for example if you’re writing a custom slider control, be sure to set the BFM_ACTION_INDRAG flag to True in those messages while in the loop.

Table Of Contents