Skip to main content
Known Participant
July 27, 2011
Question

stageWebView not resizing after using soft keyboard

  • July 27, 2011
  • 2 replies
  • 1717 views

Viewing web pages in my Adobe Air app using stageWebView works fairly well. However, whenever I use the soft keyboard to enter data into a text field on a form, after I finish and dismiss the soft keyboard my stageWebView remains resized as it was (automatically) to view the soft keyboard. So it is approx 1/2 of the screen when it should be on the whole screen. And the space where the soft keyboard was displayed is blank. No matter what page I navigate to this situation remains until I force close the app and restart.

How would I fix this?

This topic has been closed for replies.

2 replies

September 29, 2011

Hi,I find a way to solve this problem.

Frist ,when you click textinput in stagewebview, you should turn back to flex view. You should setfoucs on a textinput which using by flex. 

Then you can use stagewebviewbriadge which javascritpt can commuicate actionscript each other.You can sent the textinput value using by flex to the textinput using by html.

Here some main code:

  

   public var webView:StageWebViewBridge;

   public var boxColor:Sprite = new Sprite();

  

  

   public function addedToStageHandler()

   {    

    initUI()

   }

  

   protected function removedFromStageHandler():void

   {

    webView.dispose();

    stage.removeEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE,resize1);

    stage.removeEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChangeHandler);

   }

  

   protected function orientationChangeHandler(event:StageOrientationEvent):void

   {

    resizeWebView();

   }

  

   protected function resizeWebView():void

   {

    webView.viewPort = new Rectangle(5,100,stage.width-10,stage.height-200);

   }

   private function initUI():void

   {

   

    stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChangeHandler);

    stage.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE,resize1);

    StageWebViewBridge.DEBUGMODE=false;

    StageWebViewBridge.setRootFolder('htmlFiles');

   

    webView = new StageWebViewBridge();

   

    webView.stage = this.stage;

    stage_height=stage.height;

    stage_width=stage.width;

    resizeWebView();

    webView.loadURL("http://192.168.1.101/WebForm/Woman.aspx");

    addJavascriptCallBacks();

   

   

   }

  

  

  

  

   private var inputname:String;

   private function resize(str0:String,str:String,str1:String):void

   {

   

    webView.viewPort = null;

    astext.setFocus();

    inputname=str;

    container.visible=true;

    aslabel.text=decodeURI(str0);

    astext.text=decodeURI(str1);

   }

  

   private var stage_height:Number;

   private var stage_width:Number;

  

   private function resize1(e:SoftKeyboardEvent):void

   {

    webView.viewPort = new Rectangle(5,100,stage_width,stage_height-90);

    webView.bridge.call("resizeJS",null,inputname,URLEncodeChange(astext.text,"UTF-8"));

    container.visible=false;

   

   }

  

  

   public function addJavascriptCallBacks():void

   {

    webView.bridge.addCallback("backMain",backMain);

    webView.bridge.addCallback("resize",resize);

   }

  

  

  

   private function backMain(str:String):void

   {

    trace(str)

//    navigator.pushView(LivingPeopleMainView);

   

   }

  

  

   protected function asbtn_clickHandler(event:MouseEvent):void

   {

    // TODO Auto-generated method stub

   

    webView.viewPort = new Rectangle(5,100,stage_width,stage_height-90);

    webView.bridge.call("resizeJS",null,inputname,URLEncodeChange(astext.text,"UTF-8"));

    container.visible=false;

   

   }

  

   public  function URLEncodeChange(p:String,chartSet:String):String{

    var result:String ="";

    var byte:ByteArray =new ByteArray();

    byte.writeMultiByte(p,chartSet);

    for(var i:int;i<byte.length;i++){

     result += escape(String.fromCharCode(byte));

    

    }

    return result;

   }

  

  

  

  ]]>

</fx:Script>

<s:navigationContent>

  <s:Button label="后退" click="navigator.popView()"/>

</s:navigationContent>

<s:VGroup id="container" visible="false">

  <s:HGroup>

   <s:Label id="aslabel">

   

   </s:Label>

   <s:TextInput id="astext">

   

   </s:TextInput>

  </s:HGroup>

 

  <s:Button id="asbtn" label="确定" click="asbtn_clickHandler(event)"/>

</s:VGroup>

</s:View>

July 28, 2011

Hi snorky,

Can you please share the app/code snippet to reproduce the issue?

Thanks,

Abhishake