<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive'  version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' https://www.web3d.org/specifications/x3d-3.0.xsd ' >
<head>
<meta name='titlecontent=' KeySensorActivationKeySwitchTest.x3d '/>
<meta name='descriptioncontent='A simple scene to show KeySensor functionality using Text nodes.'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='22 June 2001'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name=' warning content=" This doesn't work because there is no KeySensor implementation yet! Prototype script (written in Java) or native node support for KeySensor is needed. "/>
<meta name=' warning content=' enabled accessType needs to be changed to exposedField once supported by Script capabilities '/>
<meta name='referencecontent=' https://www.web3d.org/x3d/specification-2000july/part1/nodesDef.html#KeySensor '/>
<meta name='referencecontent=' https://www.web3d.org/x3d/sai/javadoc/org/web3d/x3d/sai/Core/KeySensor.html '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/development/KeySensorActivationKeySwitchTest.x3d '/>
<meta name='referencecontent=' https://www.web3d.org/x3d/content/examples/Basic/ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTest.x3d '/>
<meta name='subjectcontent='KeySensor'/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<!-- The KeySensor prototype can be omitted if native-node Keysensor support is provided by the VRML browser. -->
<WorldInfo title='KeySensorActivationKeySwitchTest.x3d'/>
<ProtoDeclare name='KeySensor'>
<ProtoInterface>
<!-- warning: enabled needs to become an exposedField once Scripts support exposedField -->
<field name='enabledtype='SFBoolvalue='trueaccessType='initializeOnly'/>
<field name='set_enabledtype='SFBoolaccessType='inputOnly'/>
<field name='enabled_changedtype='SFBoolaccessType='outputOnly'/>
<field name='isActivetype='SFBoolaccessType='outputOnly'/>
<field name='keyPresstype='SFInt32accessType='outputOnly'/>
<field name='keyReleasetype='SFInt32accessType='outputOnly'/>
<field name='actionKeyPresstype='SFInt32accessType='outputOnly'/>
<field name='actionKeyReleasetype='SFInt32accessType='outputOnly'/>
<field name='altKeytype='SFBoolaccessType='outputOnly'/>
<field name='controlKeytype='SFBoolaccessType='outputOnly'/>
<field name='shiftKeytype='SFBoolaccessType='outputOnly'/>
</ProtoInterface>
<ProtoBody>
<!-- First node in prototype indicates node type, use Group so that this sensor is ChildNodeType. -->
<Group>
<Script DEF='KeySensorScript'>
<field name='altKeytype='SFBoolaccessType='outputOnly'/>
<field name='keyPresstype='SFInt32accessType='outputOnly'/>
<field name='set_enabledtype='SFBoolaccessType='inputOnly'/>
<field name='keyReleasetype='SFInt32accessType='outputOnly'/>
<field name='enabledtype='SFBoolaccessType='initializeOnly'/>
<field name='shiftKeytype='SFBoolaccessType='outputOnly'/>
<field name='actionKeyReleasetype='SFInt32accessType='outputOnly'/>
<field name='isActivetype='SFBoolaccessType='outputOnly'/>
<field name='actionKeyPresstype='SFInt32accessType='outputOnly'/>
<field name='enabled_changedtype='SFBoolaccessType='outputOnly'/>
<field name='controlKeytype='SFBoolaccessType='outputOnly'/>
<IS>
<connect nodeField='enabledprotoField='enabled'/>
<connect nodeField='set_enabledprotoField='set_enabled'/>
<connect nodeField='enabled_changedprotoField='enabled_changed'/>
<connect nodeField='isActiveprotoField='isActive'/>
<connect nodeField='keyPressprotoField='keyPress'/>
<connect nodeField='keyReleaseprotoField='keyRelease'/>
<connect nodeField='actionKeyPressprotoField='actionKeyPress'/>
<connect nodeField='actionKeyReleaseprotoField='actionKeyRelease'/>
<connect nodeField='altKeyprotoField='altKey'/>
<connect nodeField='controlKeyprotoField='controlKey'/>
<connect nodeField='shiftKeyprotoField='shiftKey'/>
</IS>
<![CDATA[
            
ecmascript:

// Native support for KeySensor node
// or keyboard-access code needed!

          
]]>
</Script>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ============================================ -->
<!-- Enabling this KeySensor (from TouchSensor.isActive) disables all other KeySensors. -->
<!-- ROUTE information for SingleKeySensor node:  [from StartMessageTouched.isOver to enabled ] [from actionKeyPress to ActivationKeyMessageSwitch.whichChoice ] -->
<KeySensor DEF='SingleKeySensorenabled='false'/>

<Billboard>
<Transform translation='0 2 0'>
<Shape>
<Text string='"Touch this text to enable" "KeySensor activation keys then" "press activation keys to test"'>
<FontStyle DEF='MiddleMiddlejustify='"MIDDLE" "MIDDLE"'/>
</Text>
<Appearance>
<Material diffuseColor='0.9 0.9 0.4'/>
</Appearance>
</Shape>
<!-- ROUTE information for StartMessageTouched node:  [from isOver to SingleKeySensor.enabled ] -->
<TouchSensor DEF='StartMessageToucheddescription='Touch this text to enable KeySensor activation keys then press activation keys to test'/>

< ROUTE  fromNode=' StartMessageTouched' fromField='isOver' toNode=' SingleKeySensor' toField='enabled'/>
</Transform>
<Transform translation='0 -1 0'>
<!-- ROUTE information for ActivationKeyMessageSwitch node:  [from SingleKeySensor.actionKeyPress to whichChoice ] -->
<Switch DEF='ActivationKeyMessageSwitchwhichChoice='0'>
<!-- ROUTE is not treated as a selectable child of Switch -->
< ROUTE  fromNode=' SingleKeySensor' fromField='actionKeyPress' toNode=' ActivationKeyMessageSwitch' toField='whichChoice'/>
<Shape DEF='Zero'>
<Text string='"No activation keypress sensed...."'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance DEF='SelectionAppearance'>
<Material diffuseColor='0 1 0'/>
</Appearance>
</Shape>
<Shape DEF='One'>
<Text string='"F1"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Two'>
<Text string='"F2"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Three'>
<Text string='"F3"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Four'>
<Text string='"F4"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Five'>
<Text string='"F5"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Six'>
<Text string='"F6"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Seven'>
<Text string='"F7"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Eight'>
<Text string='"F8"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Nine'>
<Text string='"F9"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Ten'>
<Text string='"F10"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Eleven'>
<Text string='"F11"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Twelve'>
<Text string='"F12"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Thirteen'>
<Text string='"13: HOME"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Fourteen'>
<Text string='"14: END"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Fifteen'>
<Text string='"15: LEFT"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Sixteen'>
<Text string='"16: RIGHT"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Seventeen'>
<Text string='"17: UP"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Eighteen'>
<Text string='"18: DOWN"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Nineteen'>
<Text string='"19: PGUP"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
<Shape DEF='Twenty'>
<Text string='"20: PGDN"'>
<FontStyle USE=' MiddleMiddle'/>
</Text>
<Appearance USE=' SelectionAppearance'/>
</Shape>
</Switch>
</Transform>
</Billboard>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: ActivationKeyMessageSwitch, Eight, Eighteen, Eleven, Fifteen, Five, Four, Fourteen, KeySensorScript, MiddleMiddle, Nine, Nineteen, One, SelectionAppearance, Seven, Seventeen, SingleKeySensor, Six, Sixteen, StartMessageTouched, Ten, Thirteen, Three, Twelve, Twenty, Two, Zero

Index for ProtoDeclare definition: KeySensor
-->

Event Graph ROUTE Table entries with 2 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

StartMessageTouched
TouchSensor
isOver
SFBool

ROUTE
event to
(1)
SingleKeySensor
KeySensor
enabled
SFBool

 
 
then
SingleKeySensor
KeySensor
actionKeyPress
SFInt32

ROUTE
event to
(2)
ActivationKeyMessageSwitch
Switch
whichChoice
SFInt32



-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/Basic/development/KeySensorActivationKeySwitchTestIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/KeySensorActivationKeySwitchTest.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->