This is an automated email from the ASF dual-hosted git repository.
carlosrovira pushed a commit to branch feature/themes
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/feature/themes by this push:
new 4618cdd Add textinput
4618cdd is described below
commit 4618cddc160afbfa3a50eee501a18bb75cfb57b9
Author: Carlos Rovira <[email protected]>
AuthorDate: Sat Feb 10 18:39:58 2018 +0100
Add textinput
---
.../royale/VividExample/src/main/royale/App.mxml | 2 +-
.../src/main/royale/ButtonPlayGround.mxml | 5 +
.../src/main/royale/TextInputPlayGround.mxml | 5 +-
.../projects/Vivid/src/main/resources/defaults.css | 9 +
.../Vivid/src/main/resources/vivid-manifest.xml | 1 +
.../royale/org/apache/royale/vivid/TextInput.as | 184 +++++++++++++++++++++
6 files changed, 203 insertions(+), 3 deletions(-)
diff --git a/examples/royale/VividExample/src/main/royale/App.mxml
b/examples/royale/VividExample/src/main/royale/App.mxml
index c3aeb3b..5a1c3f3 100644
--- a/examples/royale/VividExample/src/main/royale/App.mxml
+++ b/examples/royale/VividExample/src/main/royale/App.mxml
@@ -34,7 +34,7 @@
<js:VerticalLayout />
</js:beads>
<local:ButtonPlayGround/>
- <!--<local:TextInputPlayGround/>-->
+ <local:TextInputPlayGround/>
</js:View>
</js:initialView>
diff --git a/examples/royale/VividExample/src/main/royale/ButtonPlayGround.mxml
b/examples/royale/VividExample/src/main/royale/ButtonPlayGround.mxml
index a3bf90e..2384a99 100644
--- a/examples/royale/VividExample/src/main/royale/ButtonPlayGround.mxml
+++ b/examples/royale/VividExample/src/main/royale/ButtonPlayGround.mxml
@@ -29,8 +29,13 @@ limitations under the License.
}
]]>
</fx:Script>
+
+ <js:beads>
+ <js:VerticalLayout/>
+ </js:beads>
<v:Button id="button" text="Button" width="120" height="40"/>
+ <v:Button id="button2" text="Button2" width="120" height="40"/>
<v:Slider id="slider" width="250" value="120" minimum="50" maximum="250"
valueChange="onValueChange(event)"/>
diff --git
a/examples/royale/VividExample/src/main/royale/TextInputPlayGround.mxml
b/examples/royale/VividExample/src/main/royale/TextInputPlayGround.mxml
index 643ba46..f8397cc 100644
--- a/examples/royale/VividExample/src/main/royale/TextInputPlayGround.mxml
+++ b/examples/royale/VividExample/src/main/royale/TextInputPlayGround.mxml
@@ -18,10 +18,11 @@ limitations under the License.
-->
<js:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:js="library://ns.apache.org/royale/basic" >
+ xmlns:js="library://ns.apache.org/royale/basic"
+ xmlns:v="library://ns.apache.org/royale/vivid">
- <js:TextInput text="Text Input" width="120" height="40"/>
+ <v:TextInput text="Text Input" width="120" height="40"/>
</js:Group>
diff --git a/frameworks/projects/Vivid/src/main/resources/defaults.css
b/frameworks/projects/Vivid/src/main/resources/defaults.css
index 187050e..334bcd6 100644
--- a/frameworks/projects/Vivid/src/main/resources/defaults.css
+++ b/frameworks/projects/Vivid/src/main/resources/defaults.css
@@ -48,6 +48,14 @@ Button:active {
color: #FFFFFF;
}
+TextInput
+{
+ border: 1px solid #808080;
+ border-radius: 2px;
+ padding: 4px;
+ margin: 0px;
+}
+
/*
* Vivid Slider
*/
@@ -63,6 +71,7 @@ Slider {
}
.SliderThumb {
position: absolute;
+ border-radius: 15px;
}
@media -royale-swf
diff --git a/frameworks/projects/Vivid/src/main/resources/vivid-manifest.xml
b/frameworks/projects/Vivid/src/main/resources/vivid-manifest.xml
index 248f2b4..125542a 100644
--- a/frameworks/projects/Vivid/src/main/resources/vivid-manifest.xml
+++ b/frameworks/projects/Vivid/src/main/resources/vivid-manifest.xml
@@ -23,6 +23,7 @@
<component id="Application" class="org.apache.royale.vivid.Application"/>
<component id="Button" class="org.apache.royale.vivid.Button"/>
+ <component id="TextInput" class="org.apache.royale.vivid.TextInput"/>
<component id="Slider" class="org.apache.royale.vivid.Slider"/>
<component id="VerticalSliderLayout"
class="org.apache.royale.vivid.beads.layouts.VerticalSliderLayout" />
<component id="HorizontalSliderLayout"
class="org.apache.royale.vivid.beads.layouts.HorizontalSliderLayout" />
diff --git
a/frameworks/projects/Vivid/src/main/royale/org/apache/royale/vivid/TextInput.as
b/frameworks/projects/Vivid/src/main/royale/org/apache/royale/vivid/TextInput.as
new file mode 100644
index 0000000..f23a60c
--- /dev/null
+++
b/frameworks/projects/Vivid/src/main/royale/org/apache/royale/vivid/TextInput.as
@@ -0,0 +1,184 @@
+//
+// 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.royale.vivid
+{
+ import org.apache.royale.core.ITextModel;
+ import org.apache.royale.core.UIBase;
+ import org.apache.royale.events.Event;
+ COMPILE::JS
+ {
+ import goog.events;
+ import org.apache.royale.core.WrappedHTMLElement;
+ import org.apache.royale.html.util.addElementToWrapper;
+ }
+
+ /**
+ * Dispatched when the user changes the text.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ [Event(name="change", type="org.apache.royale.events.Event")]
+
+ /**
+ * The TextInput class implements the basic control for
+ * single-line text input.
+ *
+ * @toplevel
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public class TextInput extends UIBase
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public function TextInput()
+ {
+ super();
+
+ COMPILE::SWF
+ {
+ model.addEventListener("textChange", textChangeHandler);
+ }
+ }
+
+ /**
+ * @copy org.apache.royale.html.Label#text
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ * @royaleignorecoercion HTMLInputElement
+ */
+ [Bindable(event="change")]
+ public function get text():String
+ {
+ COMPILE::SWF
+ {
+ return ITextModel(model).text;
+ }
+ COMPILE::JS
+ {
+ return (element as HTMLInputElement).value;
+ }
+ }
+
+ /**
+ * @private
+ * @royaleignorecoercion HTMLInputElement
+ */
+ public function set text(value:String):void
+ {
+ COMPILE::SWF
+ {
+ inSetter = true;
+ ITextModel(model).text = value;
+ inSetter = false;
+ }
+ COMPILE::JS
+ {
+ (element as HTMLInputElement).value = value;
+ dispatchEvent(new Event('textChange'));
+ }
+ }
+
+ /**
+ * @copy org.apache.royale.html.Label#html
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ * @royaleignorecoercion HTMLInputElement
+ */
+ [Bindable(event="change")]
+ public function get html():String
+ {
+ COMPILE::SWF
+ {
+ return ITextModel(model).html;
+ }
+ COMPILE::JS
+ {
+ return (element as HTMLInputElement).value;
+ }
+ }
+
+ /**
+ * @private
+ * @royaleignorecoercion HTMLInputElement
+ */
+ public function set html(value:String):void
+ {
+ COMPILE::SWF
+ {
+ ITextModel(model).html = value;
+ }
+ COMPILE::JS
+ {
+ (element as HTMLInputElement).value = value;
+ dispatchEvent(new Event('textChange'));
+ }
+ }
+
+ private var inSetter:Boolean;
+
+ /**
+ * dispatch change event in response to a textChange event
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public function textChangeHandler(event:Event):void
+ {
+ if (!inSetter)
+ dispatchEvent(new Event(Event.CHANGE));
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ override protected function createElement():WrappedHTMLElement
+ {
+ addElementToWrapper(this,'input');
+ element.setAttribute('type', 'text');
+ element.className = 'TextInput';
+ typeNames = 'TextInput';
+
+ //attach input handler to dispatch royale change event when user
write in textinput
+ //goog.events.listen(element, 'change', killChangeHandler);
+ goog.events.listen(element, 'input', textChangeHandler);
+ return element;
+ }
+
+ }
+}
--
To stop receiving notification emails like this one, please contact
[email protected].