mobile - What options are available for handling text input on Android using Adobe AIR? -


what options available handling text input on android using adobe air? advantages , drawbacks each option?

the current options available air developers on android handling text input are:

  • stagetext native text (default)
  • textinputskin (spark.skins.mobile)
  • textinputskin (spark.skins.spark)
  • stagetext + textinputskin (spark.skins.mobile) hybrid
  • stagewebview (explained below)
  • native view

i'll discuss of advantages , drawbacks of each approach below. if i've missed (or if have other ideas haven't thought about) please let me know!


stagetext

by default, textinputs running on mobile devices make use of stagetext (native text) input. stagetext offers several advantages, adobe outlines in online documentation, including auto-correct, customization of software keyboards, etc.

the biggest disadvantage using stagetext described in bugbase ticket 3302441. stagetext's positioning becomes broken when user scrolls. textfields appear outside of respective textinputs or, worse, inside of other textinputs. work-around defect design ui not allow scrolling. can difficult mobile phones , phablets.


textinputskin (spark.skins.mobile)

this component uses styleabletextfield internally. optimized mobile use.

this component inserts additional, arbitrary characters textinput user typing on android versions (ex. nook running android 2.3, kindle hd running android 4.0). see bugbase ticket 3547601.

if application localized english (or latin-based languages) , not need support older android versions component may work you.


textinputskin (spark.skins.spark)

this component uses richeditabletext internally. not optimized mobile use. beyond demonstrates several defects (listed above) make unsuitable use.

this component not handle double-byte characters (in languages such korean). these characters seem inserted textinput (the cursor progresses, visibly) no text rendered user. (it possible issue resolved using embedded font.) see bugbase ticket 3547591.

while testing 3rd item mentioned above (input not being accepted on devices) interesting thing observed. after typing couple of characters, if user switches focus textinput uses default stagetext, @ least of missing characters automatically inserted new field.


stagetext + textinputskin (spark.skins.mobile) hybrid

this approach combines benefits of stagetext scrolling functionality of textinputskin (spark.skins.mobile). general idea create 1 textinput uses stagetext , assign fixed location on screen. textinput should hidden default. other textinputs (using textinputskin) can created , positioned needed on stage. when 1 of these textinputs gains focus, hidden surrogate textinput should shown , focus should shifted it. text entered surrogate, change-handler should copy text user-selected textinput. when user tabs or clicks set focus elsewhere surrogate textinput should hidden again.

i can provide code example of if desired. there couple of drawbacks approach (mentioned above) it's possible fault of implementation.


stagewebview

this approach involves displaying simple html page inside of air application using stagewebview. html page contains <input type="text"> objects make use of android's native text , software keyboard. communicating between html page , parent air app though bit tricky, since stagewebview not support flash-to-javascript communication in same externalinterface.

communicating javascript flash

communicating javascript (or html) actionscript difficult because stagewebview not allow actionscript add callbacks. stagewebviewbridge offers functionality has not been updated in time , when tried it, unable content display using flex 4.6 , air 3.5.

there still ways convey information actionscript using locationchangeevent. idea behind air app listen location changing events , parse incoming event.location information. simple links works things more complicated when comes forms. tried following approaches before settling on one:

communicating flash javascript

to communicate javascript (call methods, pass parameters) use stagewebview's loadurl method this:

_stagewebview.loadurl( 'javascript:yourmethodname( "a string", true )' ); 

unfortunately loadurl method has void return type (meaning can't retrieve data way).

other difficulties

the biggest drawback approach described in bugbase ticket 3535948. if air application uses <rendermode>direct</rendermode> or <fullscreen>true</fullscreen> text input via stagewebview unusable. (response sluggish. users unable select or delete characters.) if app not require either of flags route may work you.

one workaround fullscreen limitation disable fullscreen mode when application needs make use of stagewebview. can done stagedisplaystate this:

// turn off fullscreen stage.displaystate = stagedisplaystate.normal;  // turn on fullscreen stage.displaystate = stagedisplaystate.full_screen_interactive; 

native view

the last remaining option (that i'm aware of) write native extension displays text-inputs , returns data air application. safest (although disappointing) option of ones discussed in thread.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -