Click or drag to resize
SoEventCallback Class

Node which invokes callbacks for events.

Inheritance Hierarchy

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 9.9.12.0 (9.9.12.0)
Syntax
public class SoEventCallback : SoNode

The SoEventCallback type exposes the following members.

Constructors
  NameDescription
Public methodSoEventCallback

Constructor creates an event callback node with no event interest and a NULL path.

Top
Methods
  NameDescription
Public methodAddEventCallback(Type, SoEventCallbackEventCB)

Add an event delegate.

Public methodAddEventCallback(Type, SoEventCallbackEventUserDataCB, Object) Obsolete.
Adds event delegate.
Public methodAffectsState

Returns true if a node has an effect on the state during traversal.

(Inherited from SoNode.)
Public methodCallback
(Inherited from SoNode.)
Public methodCopy
Calls Copy(false).
(Inherited from SoNode.)
Public methodCopy(Boolean)

Creates and returns an exact copy of the node.

(Inherited from SoNode.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodDistribute
(Inherited from SoNode.)
Public methodDoAction
(Inherited from SoNode.)
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAction

Returns the SoHandleEventAction currently traversing this node, or NULL if traversal is not taking place.

Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetAlternateRep

This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type).

(Inherited from SoNode.)
Public methodGetBoundingBox
(Inherited from SoNode.)
Public methodGetEvent

Returns the event currently being handled, or NULL if traversal is not taking place.

Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetMatrix
(Inherited from SoNode.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetPath

Gets the path which must be picked in order for the callbacks to be invoked.

Public methodGetPickedPoint

Returns pick information during SoHandleEventAction traversal, or NULL if traversal is not taking place.

Public methodGetPrimitiveCount
(Inherited from SoNode.)
Public methodGetRenderUnitID
(Inherited from SoNode.)
Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGLRender
(Inherited from SoNode.)
Public methodGLRenderBelowPath
(Inherited from SoNode.)
Public methodGLRenderInPath
(Inherited from SoNode.)
Public methodGLRenderOffPath
(Inherited from SoNode.)
Public methodGrabEvents

Tells the event callback node to grab events.

Public methodGrabEventsCleanup
(Inherited from SoNode.)
Public methodGrabEventsSetup
(Inherited from SoNode.)
Public methodHandleEvent
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodIsBoundingBoxIgnoring

This method is used by getBoundingBox action traversal to know if the current node must be traversed or not, ie the bounding should be ignored.

(Inherited from SoNode.)
Public methodIsHandled

Returns whether the event has been handled.

Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsOverride

Returns the state of the override flag.

(Inherited from SoNode.)
Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodPick
(Inherited from SoNode.)
Public methodRayPick
(Inherited from SoNode.)
Public methodReleaseEvents

Tells the event callback node to release the grab of events.

Public methodRemoveEventCallback(Type, SoEventCallbackEventCB)

Removes a previously specified event delegate.

Public methodRemoveEventCallback(Type, SoEventCallbackEventUserDataCB) Obsolete.
Remove the delegate from the invocation list.
Public methodSearch
(Inherited from SoNode.)
Public methodSet

Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.

(Inherited from SoFieldContainer.)
Public methodSetHandled

Tells the node the event was handled.

Public methodSetName (Inherited from SoBase.)
Public methodSetOverride

Turns the override flag on or off.

(Inherited from SoNode.)
Public methodSetPath

Sets the path which must be picked in order for the callbacks to be invoked.

Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoNode.)
Public methodWrite
(Inherited from SoNode.)
Top
Properties
  NameDescription
Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Top
Remarks

SoEventCallback will invoke application supplied delegatesduring SoHandleEventAction traversal. Methods allow the application to specify which Open Inventor events should trigger callbacks, and which path must be picked, if any, for the delegateinvocation to occur. The application delegateis able to get information about the event and the pick detail, and may grab events, release events, and set whether the event was handled.

If you register more than one delegatein an SoEventCallback node, all the delegateswill be invoked when an event occurs, even if one of the callbacks handles the event. However, if the event is handled (i.e. SetHandledis called) by any of the delegates, no subsequent node in the scene graph will see the event. Generally SoEventCallback nodes should be placed near the beginning of the scene graph, so the SoHandleEventAction does not need to traverse the rest of the scene graph if the event is handled. Note that events may be handled by other nodes in the scene graph, for example draggers and manipulators. If the event is handled before the SoEventCallback node is traversed, then none of the delegateswill be invoked.

Remember that when using the Open Inventor viewer classes, SoHandleEventAction traversal is only done when the viewer is in "selection" mode (the arrow cursor is displayed). Also note that some methods may only be called from the delegate.

When invoked, this SoEventCallback node will be passed to the delegate. Using this object, you can get the event being handled (getEvent()) and query what geometry is under the cursor (getPickedPoint()). These are convenient wrappers around the corresponding methods in the SoHandleEventAction (which you can get using getAction()).

Picking: When getPickedPoint() is called, the handle event action automatically applies an SoRayPickAction to the scene graph using the cursor position in the event. The handle event action remembers the result in case another node needs pick information during the traversal. Often this is more convenient than creating and applying a pick action explicitly.

But note: The handle event action does not enable computation of normal vectors and texture coordinates in the pick action that it creates internally. If you need the normal vector at the point of intersection of the pick ray, then you must create your own pick action and apply it. In this case you can get the node to apply the pick action to by calling the handle event action's getPickRoot() method.

EXAMPLE

An event callback node that handles key and button events

SoEventCallback eventNode = new SoEventCallback();
eventNode.AddEventCallback( typeof(SoKeyboardEvent)   , new SoEventCallback.EventCB(keyEventCB) );
eventNode.AddEventCallback( typeof(SoMouseButtonEvent), new SoEventCallback.EventCB(btnEventCB) );
. . .
Handler for key press events
private void keyEventCB( SoEventCallback node )
{
 SoKeyboardEvent evt = (SoKeyboardEvent)node.GetEvent();
 if (evt.GetKey() == SoKeyboardEvent.Keys.UP_ARROW)
 {
   // Do something, then tell action to stop traversal
   node.SetHandled();
 }
 else if (evt.GetKey() == SoKeyboardEvent.Keys.DOWN_ARROW)
 {
   // Do something, then tell action to stop traversal
   node.SetHandled();
 }
}
Handler for mouse button events
private void btnEventCB( SoEventCallback node )
{
   SoMouseButtonEvent evt = (SoMouseButtonEvent)node.GetEvent();
   // If button 1 was pressed
   if (SoMouseButtonEvent.IsButtonPressEvent( evt, SoMouseButtonEvent.Buttons.BUTTON1 ))
   {
       // Check if any geometry is under the cursor
       SoHandleEventAction action = node.GetAction();
       SoPickedPoint     pickedPt = action.GetPickedPoint();
       if (pickedPt != null)
       {
           SoFullPath pickedPath = (SoFullPath)pickedPt.GetPath();
           SoNode     pickedNode = pickedPath.GetTail();
       }
   }
}

FILE FORMAT/DEFAULT

EventCallback { }

See Also