media @ VU
[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

talk show tell print

proto-rif-interface-editbox.vr

proto-rif-interface-editbox.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  

editbox


  

Web3D/VR

#@extern @vr-extern-proto-object-box.wrl PROTO EditBox [ eventIn SFString characterInput eventOut MFString lineOutput field SFVec2f position 0 0 field SFVec2f size 1 1 field SFFloat fontSize 0.05 exposedField SFFloat transparency 0 ] { DEF TRANSFORM Transform { children [ DEF TEXTTRANSFORM Transform { children [ Shape { appearance Appearance { material Material { emissiveColor 0 0 0 diffuseColor 0 0 0 } } geometry DEF TEXT Text { string "<enter text here>" fontStyle FontStyle { family "TYPEWRITER" style "BOLD" size IS fontSize } } } ] } DEF BOXTRANSFORM Transform { children [ Shape { appearance Appearance { material Material { transparency IS transparency emissiveColor 1 1 1 diffuseColor 0 0 0 } } geometry DEF BOX box {} } ] } ] } DEF SCRIPT Script { field SFNode transformNode USE TRANSFORM eventOut SFVec3f boxNodeSize field SFNode boxTransform USE BOXTRANSFORM field SFNode textNode USE TEXT field SFNode textTransform USE TEXTTRANSFORM field SFVec2f position IS position field SFVec2f size IS size field SFFloat fontSize IS fontSize field SFInt32 maxLength 0 eventIn SFString characterInput IS characterInput eventOut MFString lineOutput IS lineOutput field MFString temp [] eventOut MFString tempOutput field SFString line NULL url "vrmlscript: function initialize() { transformNode.translation = new SFVec3f(position.x,position.y,0); boxNodeSize = new SFVec3f(size.x,size.y,0.01); boxTransform.translation = new SFVec3f(size.x/2,-size.y/2,0); textTransform.translation = new SFVec3f(0,-fontSize,0.015); // The maxLength is an approximation based upon experimentation in // getting the right size... maxLength = (size.x/fontSize)*1.9; line = ''; } function characterInput(value,time) { if(value == '\n') { temp[0] = line; lineOutput = temp; line = ''; temp[0] = ''; } else { if(value =='\b' || value=='\d') { line = line.substring(0,line.length-1); } else { line = line + value; } if(maxLength>0 && maxLength<line.length) { temp[0] = line.substring(line.length-maxLength,line.length); } else { temp[0] = line; } } tempOutput = temp; } " } ROUTE SCRIPT.boxNodeSize TO BOX.size ROUTE SCRIPT.tempOutput TO TEXT.string }


(C) A. Eliëns 21/5/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.