/*---------------- FILE HEADER --------------------------------------- This file is part of Geoide. Copyright (C) 2005-2006 by: IDgis B.V. http://www.idgis.nl This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: Herman Assink IDgis bv P.O. Box 15 7450 AA Holten The Netherlands E-Mail: herman.assink@idgis.nl * @version 1.4.0 * @author IDgis team * ------------------------------------------------------------------------*/ import mx.controls.Button; import mx.utils.Delegate; import nl.idgis.giclient.util.Strings; import nl.idgis.giclient.gui.ContainerContent; import nl.idgis.giclient.Ruler; class nl.idgis.giclient.framework.TextInputFrame extends ContainerContent { private var returnObject:Object = null; private var returnFunction:Function = null; private var question:String = null; private var inputType:String = null; //private var answerGiven:Boolean = false; private var okButton:Button = null; private var cancelButton:Button = null; private var userInput:String = null; private var textFormat:TextFormat; private var ruler:Ruler; //private var intervalID:Number = 0; function onLoad():Void { question = frame.contentProperties.question; returnObject = frame.contentProperties.returnObject; ruler = frame.contentProperties.ruler; returnFunction = frame.contentProperties.returnFunction; inputType = frame.contentProperties.inputType; textFormat = new TextFormat(); textFormat.font = "_sans"; //textField to show question createTextField("textField", 0, 5, 5, 200, 30); this["textField"].multiline = true; this["textField"].wordWrap = true; this["textField"].setNewTextFormat(textFormat); this["textField"].text = question; //textInput to fetch the user input attachMovie("TextInput", "textInput", 6); this["textInput"]._x = 10; this["textInput"]._y = 35; this["textInput"].setSize(70, 25); if (inputType == "Number"){ this["textInput"].restrict = "0-9."; } okButton = Button(attachMovie("Button", "okButton_mc", 1, {_x: 10, _y: 70, _width: 80, label: "OK"})); okButton.addEventListener("click", Delegate.create(this,onClickOKButton)); cancelButton = Button(attachMovie("Button", "cancelButton_mc", 2, {_x: 110, _y: 70, _width: 80, label: Strings.getFile("Geoide").getString("Cancel")})); cancelButton.addEventListener("click", Delegate.create(this, onClickCancelButton)); _parent.refreshPane(); //intervalID = setInterval(this,"returnInput", 250); } function onClickOKButton(eventObject:Object):Void { //answerGiven = true; userInput = this["textInput"].text; returnInput(); } function onClickCancelButton(eventObject:Object):Void { //answerGiven = true; userInput = null; returnInput(); } private function returnInput():Void { //if (this.answerGiven == true){ if(userInput!= null) { if (inputType == "Number"){ if (userInput == ""){ if(returnFunction == null){ returnObject.catchUserInput(0); } else { returnFunction.call(returnObject,0); } } else { if(returnFunction == undefined){ returnObject.catchUserInput(Number(userInput)); } else { returnFunction.call(returnObject,Number(userInput)); } } }else{ if(returnFunction == undefined){ returnObject.catchUserInput(userInput); } else { returnFunction.call(returnObject,userInput); } } }else { if(returnFunction == undefined){ returnObject.catchUserInput(null); } else { returnFunction.call(returnObject,null); } } //} } }