You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/07/06 20:04:31 UTC
svn commit: r960969 - in /pivot/trunk/examples: ./ .settings/ src/ src/org/
src/org/apache/ src/org/apache/pivot/ src/org/apache/pivot/examples/
src/org/apache/pivot/examples/keyboard/
Author: gbrown
Date: Tue Jul 6 18:04:30 2010
New Revision: 960969
URL: http://svn.apache.org/viewvc?rev=960969&view=rev
Log:
Add examples project.
Added:
pivot/trunk/examples/
pivot/trunk/examples/.classpath
pivot/trunk/examples/.project
pivot/trunk/examples/.settings/
pivot/trunk/examples/src/
pivot/trunk/examples/src/org/
pivot/trunk/examples/src/org/apache/
pivot/trunk/examples/src/org/apache/pivot/
pivot/trunk/examples/src/org/apache/pivot/examples/
pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/
pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java
pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml
Added: pivot/trunk/examples/.classpath
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/.classpath?rev=960969&view=auto
==============================================================================
--- pivot/trunk/examples/.classpath (added)
+++ pivot/trunk/examples/.classpath Tue Jul 6 18:04:30 2010
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/web"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/wtk"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/wtk-terra"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: pivot/trunk/examples/.project
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/.project?rev=960969&view=auto
==============================================================================
--- pivot/trunk/examples/.project (added)
+++ pivot/trunk/examples/.project Tue Jul 6 18:04:30 2010
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>examples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java?rev=960969&view=auto
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java (added)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java Tue Jul 6 18:04:30 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.examples.keyboard;
+
+import java.net.URL;
+
+import org.apache.pivot.beans.Bindable;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Alert;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.ComponentKeyListener;
+import org.apache.pivot.wtk.Keyboard;
+import org.apache.pivot.wtk.TextInput;
+import org.apache.pivot.wtk.Window;
+
+public class ComponentKeyListenerExample extends Window implements Bindable {
+ @Override
+ public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+ TextInput textInput = (TextInput)namespace.get("textInput");
+ textInput.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() {
+ @Override
+ public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
+ if (keyCode == Keyboard.KeyCode.S
+ && Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
+ Alert.alert("You pressed Control-S!", component.getWindow());
+ }
+
+ return false;
+ }
+ });
+ }
+}
Added: pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml?rev=960969&view=auto
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml (added)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/component_key_listener_example.bxml Tue Jul 6 18:04:30 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<keyboard:ComponentKeyListenerExample title="Keyboard Example" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:keyboard="org.apache.pivot.examples.keyboard"
+ xmlns="org.apache.pivot.wtk">
+ <BoxPane styles="{padding:8}">
+ <TextInput bxml:id="textInput">
+ <componentKeyListeners>
+ <bxml:script>
+ <![CDATA[
+ importPackage(java.lang);
+ importPackage(org.apache.pivot.wtk);
+
+ function keyPressed(component, keyCode, keyLocation) {
+ if (keyCode == Keyboard.KeyCode.S
+ && Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
+ System.out.println("You pressed Control-S!");
+ }
+ }
+ ]]>
+ </bxml:script>
+ </componentKeyListeners>
+ </TextInput>
+ </BoxPane>
+</keyboard:ComponentKeyListenerExample>
+