LWUIT how to allow landscape on TextArea only - use portrait for everything else
Hi all,
I'm working on a project that needs the orientation to stay in
"portrait" mode but let the user move the phone to the "landscape" position
only when text input is needed.
So, the idea is, the app remains in portrait mode until the user needs to
input some text. We're using LWUIT's TextArea component for this so we
thought there was a possibility to lock LWUIT to portrait and only use
landscape for the native Textbox implementation when it shows up, but we're
finding it difficult to prevent LWUIT from switching orientation.
Our target handsets are Nokia touchscreen devices (S60 5th edition particularly, i.e. 5800, 5230, X6,etc), so the
"Nokia-MIDlet-App-Orientation: portrait" JAD attribute pretty much did the
trick except for the native keyboard not being displayed in landscape
orientation this way - which is exactly what we need to do: 1) show the app
in portrait at all times 2) allow the native keyboard as implemented by
native TextBox implementation to be shown in landscape when text input is
required.
Any ideas are apprecitated!
Thanks in advance
Mario
Re: LWUIT how to allow landscape on TextArea only - use portrait for everything else
define your own Custom Keyboard and TextBox for this need, do not depend on native - it will be locked to Portrait with "Nokia-MIDlet-App-Orientation: portrait" - JAD.
Re: LWUIT how to allow landscape on TextArea only - use portrait for everything else
Thanks ~Amitabh
The thing is I'm using LWUIT and it handles sizeChanged() events to switch orientation and it seems I can't prevent it from doing so (unless we change LWUIT's source code which we are trying not to).
So basically, when you rotate the phone you have to be aware of this as the coordinate system changes, but you are only notified about the Canvas size change via a call to sizeChanged(). The you need to detect and assume this is an orienation change by realizing the width and height have been interchanged (i.e. 360x640 changes to 640x360). Now the touch events will have a different coordinate system which we'd also need to tweak.
So, to sum up, if I were to code my own custom keyboard or textbox, I'm in the same problem: the sizeChanged wouldn't ever be fired if the JAD attribute is set. And if we don't set it, then the sizeChanged events get fired but we need to tweak LWUIT code to handle both painting and the coordinate system.
What do you think?
Thanks for the advise
Mario
Re: LWUIT how to allow landscape on TextArea only - use portrait for everything else
You should fix the device orientation, and make a custom text field that always opens the keyboard in landscape mode [which you draw on Canvas and have the co-ordinate matrix in place to identify which key is pressed by touch event].