Setting focus on TextFields not on stage – Papervision3D
Well, I finally came up with a fix for this issue and thought to archive it. Basically, the issue is that when you have textfields in a Sprite that you use for a material source for Papervision3D, you want to be able to set focus to those text fields. Without them being on stage, however, it doesn’t work to say “stage.focus = myTextField”.
So, very simply, all you have to do is add the textfield to the stage, then use stage.focus = myTextField, then re-add back to your Sprite. Bingo, you have focus in your TextField. Now, I should say, that i’ve seen it work with just using stage.focus = myTextField, but in this particular situation, adding it to the stage first, then setting focus, then adding it back worked. So give it a whirl either way.
stage.focus = myTextField;
Bam! done. As long as you’re redrawing your material so that you can see what you’re typing ( bitmapMaterial.drawBitmap()), it’ll work just fine.
Tabbing is controlled easily with:
protected function handleKeyUp(e:KeyboardEvent):void
if( e.keyCode == 9 ) // tab
if( currentField == username )
else if( currentField == password )
hope that helps someone!