Version: 2.0.2

Events

import React from "react";
import { Content, Text, Button } from "magic-script-components";
import {
ControlPose3DofInputEventData,
ControlPose6DofInputEventData,
ControlTouchPadInputEventData,
EyeTrackingEventData,
GestureInputEventData,
InputEventData,
KeyInputEventData,
RayCastEventData,
SelectionEventData,
UiEventData,
VideoEventData
} from "magic-script-components-lumin";
export default class MyApp extends React.Component {
updateLoopHandler = (delta) => {
// delta = time delta since last frame (in seconds)
console.log(`Delta: ${delta}`);
}
eventHandler = (eventData) => {
if (eventData instanceof ControlPose3DofInputEventData) {
console.log('Event: ControlPose3DofInputEventData');
}
if (eventData instanceof ControlPose6DofInputEventData) {
console.log('Event: ControlPose6DofInputEventData');
}
if (eventData instanceof ControlTouchPadInputEventData) {
console.log(eventData.TouchCount);
}
if (eventData instanceof EyeTrackingEventData) {
console.log('Event: EyeTrackingEventData');
}
if (eventData instanceof GestureInputEventData) {
console.log('Event: GestureInputEventData');
}
if (eventData instanceof InputEventData) {
console.log('Event: InputEventData');
}
if (eventData instanceof KeyInputEventData) {
console.log('Event: KeyInputEventData');
}
if (eventData instanceof RayCastEventData) {
console.log('Event: RayCastEventData');
}
if (eventData instanceof SelectionEventData) {
console.log('Event: SelectionEventData');
}
if (eventData instanceof UiEventData) {
console.log('Event: UiEventData');
}
if (eventData instanceof VideoEventData) {
console.log('Event: VideoEventData');
}
return true;
}
render() {
return (
<Content
name="rootNode"
onUpdateLoop={this.updateLoopHandler}
onEvent={this.eventHandler}
>
<Text
textSize={0.1}
localPosition={[-0.3, 0.3, 0]}
text={'Events demo'}
/>
<Button
textSize={0.1}
localPosition={[ 0.3, 0, 0]}
text={`Press`}
/>
</Content>
);
}
}

Common Events:

  • onActivate
  • onPressed
  • onLongPress
  • onRelease
  • onHoverEnter
  • onHoverExit
  • onHoverMove
  • onEnabled
  • onDisabled
  • onFocusGained
  • onFocusLost
  • onFocusInput
  • onUpdate
  • onDeleted
  • onEvent
  • onUpdateLoop

supported by all of the following components:

  • Button
  • CircleConfirmation
  • ColorPicker
  • DatePicker
  • Dialog
  • DropdownList
  • GridLayout
  • Image
  • Line
  • LinearLayout
  • ListView
  • ListViewItem
  • PageView
  • Panel
  • PortalIcon
  • ProgressBar
  • RectLayout
  • ScrollBar
  • ScrollView
  • Slider
  • Spinner
  • Tab
  • Text
  • TextEdit
  • TimePicker
  • Toggle
  • ToggleGroup
  • View
  • WebView

The following components support onEvent and onUpdateLoop events only:

  • Audio
  • Content
  • Light
  • Model
  • Quad
  • Video

Events per component and the provided event data type:

ComponentEvent NameEvent Data Type
UI componentonActivateUiEventData
onClickUiEventData
onPressUiEventData
onLongPressUiEventData
onReleaseUiEventData
onHoverEnterUiEventData
onHoverExitUiEventData
onHoverMoveUiEventData
onEnabledUiEventData
onDisabledUiEventData
onFocusGainedUiEventData
onFocusLostUiEventData
onFocusInputUiEventData
onUpdateUiEventData
onDeleteUiEventData
onEvent*based on the event
onUpdateLoopnumber
TextEditonCharacterEnterTextEditEventData
onKeyboardEventTextEditEventData
onTextChangedTextEditEventData
SlideronSliderChangedSliderEventData
ListViewonScrollChangedScrollViewEventData
ScrollViewonScrollChangedScrollViewEventData
ProgressBaronProgressBarChangedProgressBarEventData
DropDownListonListVisibilityChangedDropDownListEventData
onSelectionChangedDropDownListEventData
ToggleonToggleChangedToggleEventData
PanelonCursorEdgeUiEventData
onCursorOffEdgeUiEventData
onPanelEnterUiEventData
onPanelExitUiEventData
DialogonCancelUiEventData
onConfirmUiEventData
ColorPickeronColorCanceledColorPickerEventData
onColorConfirmedColorPickerEventData
onColorChangedColorPickerEventData
TimePickeronTimeChangedTimePickerEventData
onTimeConfirmedTimePickerEventData
DatePickeronDateChangedDatePickerEventData
onDateConfirmedDatePickerEventData
CircleConfirmationonConfirmationCanceledUiEventData
onConfirmationCompleteUiEventData
onConfirmationUpdateUiEventData

Event data types and their properties

ServerEvent extends EventData

  • PrismId
  • isInputEvent

InputEventData extends ServerEvent

  • DeviceId
  • EventSource
  • EventType

EyeTrackingEventData extends ServerEvent

  • EyeTrackingFixationConfidence
  • EyeTrackingFixationPosition
  • EyeTrackingLeftEyeBlinkState
  • EyeTrackingLeftEyeConfidence
  • EyeTrackingLeftEyePosition
  • EyeTrackingLeftEyeRotation
  • EyeTrackingRightEyeBlinkState
  • EyeTrackingRightEyeConfidence
  • EyeTrackingRightEyePosition
  • EyeTrackingRightEyeRotation
  • RemainingTimeAtUncomfortableDepth

NodeEventData extends EventData

  • AABB
  • AnchorPosition
  • ChildCount
  • CurrentPrismTransform
  • CurrentWorldTransform
  • CursorHoverState
  • LocalAABB
  • LocalTransform
  • Name
  • NodeId
  • ParentedBoneName
  • PrismId

TransformNodeEventData extends NodeEventData

  • LocalPosition
  • LocalRotation
  • LocalScale
  • PrismPosition
  • WorldPosition

UiEventData extends TransformNodeEventData (in development)

  • Alignment
  • Enabled
  • EventPassThrough
  • EventSoundID
  • GravityWellEnabled
  • GravityWellProperties
  • RenderingLaye