Skip to content

Commit

Permalink
keycode changes impose the use of noVNC keyboard event system in all …
Browse files Browse the repository at this point in the history
…variant. Fixed broken demos, both GWT mode and stand alone mode are now possible
  • Loading branch information
cyrilmhansen committed Feb 28, 2012
1 parent 1a061ce commit ac574b4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
5 changes: 5 additions & 0 deletions build/scripts/version.compile.pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ echo -e "Created on:" >> "${FILE_CAAT}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT}"
echo -e "*/\n\n" >> "${FILE_CAAT}"


more $CAAT_SRC_DIR/modules/TextInput/noVNC_Util.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/TextInput/noVNC_Input.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/CAAT.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/core/class.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/math/affinetransform2D.js >> "${FILE_CAAT}"
Expand Down Expand Up @@ -94,6 +97,8 @@ echo -e "Created on:" >> "${FILE_CAAT_CSS}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_CSS}"
echo -e "*/\n\n" >> "${FILE_CAAT_CSS}"

more $CAAT_SRC_DIR/modules/TextInput/noVNC_Util.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/TextInput/noVNC_Input.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/CAAT.js >> "${FILE_CAAT_CSS}"
echo -e "CAAT.__CSS__=1;" >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/core/class.js >> "${FILE_CAAT_CSS}"
Expand Down
4 changes: 4 additions & 0 deletions build/scripts/version.compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ echo -e "*/\n\n" >> "${FILE_CAAT_TEXTINPUT}"
#
echo -e "\nCreating CAAT canvas/webGL"
$JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" \
--js "${SOURCE_DIR}"/modules/TextInput/noVNC_Util.js \
--js "${SOURCE_DIR}"/modules/TextInput/noVNC_Input.js \
--js "${SOURCE_DIR}"/CAAT.js \
--js "${SOURCE_DIR}"/core/browserdetect.js \
--js "${SOURCE_DIR}"/core/class.js \
Expand Down Expand Up @@ -162,6 +164,8 @@ $JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" --js
echo "Creating CAAT CSS"
echo -e "CAAT.__CSS__=1;" >> /tmp/__css.js
$JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" \
--js "${SOURCE_DIR}"/modules/TextInput/noVNC_Util.js \
--js "${SOURCE_DIR}"/modules/TextInput/noVNC_Input.js \
--js "${SOURCE_DIR}"/CAAT.js \
--js /tmp/__css.js \
--js "${SOURCE_DIR}"/core/browserdetect.js \
Expand Down
4 changes: 2 additions & 2 deletions documentation/demos/demo20/text_editor_org.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h1>Text input</h1>
</body>

<script type="text/javascript" src="../menu/menu.js"></script>
<script type="text/javascript" src="../../../build/caat.js"></script>
<script type="text/javascript" src="../../../build/caat-textinput.js"></script>
<!-- To change refresh rate, forking the template will be required -->
<script type="text/javascript" src="../templates/startup-wo-splash/template_debug.js"></script>

Expand Down Expand Up @@ -326,4 +326,4 @@ <h1>Text input</h1>
</script>


</html>
</html>
7 changes: 5 additions & 2 deletions src/model/mouseevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ CAAT.GlobalEnableEvents= function __GlobalEnableEvents() {
this.GlobalEventsEnabled= true;

// Setup and activation of NoVNC key events library
keyboard = new Keyboard({'target': MAINDOC,
if (typeof(CAAT_EVT_SRC)=='undefined') {
CAAT_EVT_SRC = window;
}
keyboard = new Keyboard({'target': CAAT_EVT_SRC,
'onKeyPress': function(keysym, down, evt) {

if (down) {
Expand Down Expand Up @@ -444,7 +447,7 @@ CAAT.GlobalEnableEvents= function __GlobalEnableEvents() {



MAINDOC.addEventListener('resize',
CAAT_EVT_SRC.addEventListener('resize',
function(evt) {
for( var i=0; i<CAAT.windowResizeListeners.length; i++ ) {
CAAT.windowResizeListeners[i].windowResized(
Expand Down
14 changes: 12 additions & 2 deletions src/modules/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
// Setup default font sprite sheet
this.setDefaultFont();

this.resetTransform();
this.setScale(1,1);
this.setScaleAnchor(1.0,1.0);
this.setRotation(0);

this.lineHeight = this.font.height;
this.textAlign= "left";
this.textBaseline= "top";
Expand Down Expand Up @@ -59,7 +64,11 @@
setOutline(true).
enableEvents(false).
setText('_').
setLocation (0, 5);
resetTransform().
setScale(1,1).
setRotation(0).
setScaleAnchor(1.0,1.0).
setPosition (0, this.font.height / 2);

this.setDefaultCursorBehavior();
this.addChild(this.cursorActor);
Expand Down Expand Up @@ -168,9 +177,10 @@
}
// console.log("setCursorPos : after " + this.cursorPos);
cursorPosx = this.font.stringWidth(this.text.substr(0 , this.cursorPos));
cursorPoxy = this.font.height / 2;

if (this.cursorActor != null) {
this.cursorActor.setLocation( cursorPosx , 0);
this.cursorActor.setPosition( cursorPosx , cursorPoxy);
}
}
},
Expand Down

0 comments on commit ac574b4

Please sign in to comment.