×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    67

    Text input in N9

    Hi

    I have a cross platform game on Symbian and Meego. My interaction with the specifics of each platform are generally based on the epong example as it seems to be the definitive / complete example for "regular" c++ / opengl engines. I am currently adding some features which require text entry from the user.

    I have text input working on both platforms using QInputDialog::getText as per the epong example. This looks and works very nicely on Symbian, however on N9 the experience is less than ideal - I have two problems:

    1. The text input widget that pops up is totally unstyled and jarring. The keyboard also only appears once the widget is tapped on again.
    2. The orientation of the widget is landscape. My game is portrait, and currently everything works well with graphic rotation in GL and an XChangeProperty call so that the volume bar, closing gesture etc are correct. However this does not seem to affect the widget.

    I see a guide at http://www.developer.nokia.com/Commu...d_applications however it expressly mentions that QDialogs should not be used with that approach to rotation.

    I know that widgets are not actually recommended or supported, so I'm wondering what the best way is to go forward on this?

  2. #2
    Super Contributor
    Join Date
    May 2008
    Location
    Helsinki, Finland
    Posts
    1,100

    Re: Text input in N9

    Hi there, magicdave

    You got some very good points and findings, I will check out here what could be the best recommended method to achieve what you were wanting to do.

    Me or someone else will be posting back to this thread.

    Best Regards,
    Marko
    [FONT="Comic Sans MS"][COLOR="Blue"][/COLOR][I]Marko Lumivuori
    Technical Support
    +358 40 8019330
    [email]marko.lumivuori@nokia.com[/email][/I][/FONT]

  3. #3
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    67

    Re: Text input in N9

    Thanks Marko! Look forward to hearing back

  4. #4
    Super Contributor
    Join Date
    May 2008
    Location
    Helsinki, Finland
    Posts
    1,100

    Re: Text input in N9

    Hi there, magicdave!

    Sure, no problem I will try to speed this up.

    Best,
    Marko
    [FONT="Comic Sans MS"][COLOR="Blue"][/COLOR][I]Marko Lumivuori
    Technical Support
    +358 40 8019330
    [email]marko.lumivuori@nokia.com[/email][/I][/FONT]

  5. #5
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Text input in N9

    Hi magicdave,
    What do you mean with "unstyled and jarring"? The input method runs in a different process and it has it's own style.
    If you are talking about the text entry widget, in this case you have to style it by yourself.
    Are you using a plain Qt text entry widget? Plain Qt text entry widget, as it's behaviour is to only activate input method when tapping a focused widget (first tap to focus, second tap to activate).

    About orientation information, it has to be passed to the input method server using the API as use by libmeegotouch.
    http://meego.gitorious.org/meegotouc...ethodstate.cpp
    Last edited by gnuton; 2012-03-09 at 13:25.

  6. #6
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    67

    Re: Text input in N9

    Hi Gnuton

    Sorry for the delay in replying, I didn't get the notification email for some reason.

    What I mean is that it looks like it is from Windows 95.
    I am using the same call from the epong example -
    QString input = QInputDialog::getText( this, QString(prompt), QString(prompt) );

    I am not trying to do anything special, I would just like to know the "correct" way to do this. It's a bit confusing because I gather that Qt widgets are not really supported on Meego, however this is what is in the current Qt game example. Is there some example code anywhere of exactly how to pop up a nice / native looking text entry from a game engine?

    Thanks for your help.

  7. #7
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Text input in N9

    Hi Dave,
    QInputDialog::getText static method shows a QDialog.
    QDialogs are QWidgets and those are not actually supported on Harmattan by Nokia.

    On Harmattan dialogs are actually QGraphicsItems.
    So there are 2 ways to follow
    1. If your game is embedded in a QGraphicsView, you can use MDialogs (deprecated API)[1] or a QML dialog[2].
    2. (EASY WAY) The other alternative is to skin the QDialog/QTextEdit and other QWidgets by using stylesheets [3]. To do this you could set the stylesheet to application level. [4]

    [1] http://apidocs.meego.com/git-tip/mtf..._m_dialog.html
    [2]http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-dialog.html
    [3] http://www.developer.nokia.com/Commu..._Qt_stylesheet
    [4] http://www.developer.nokia.com/Commu...a_QApplication

  8. #8
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    67

    Re: Text input in N9

    Hi gnuton

    My basic game structure is following the EPong example, so it is based off a QWidget, not QGraphicsView. It is a cross platform C++ opengl engine that is not Qt or Nokia specific - I am using this example and specific APIs from Qt or Meego where necessary to interact with platform specifics, such as in this case, text entry.

    Styling the QDialog will be great and this would solve the issue with looks. So thanks for that
    On the orientation issue, I looked at your suggestion to use minputmethodstate, and tried this call -
    Code:
    MInputMethodState::instance()->setActiveWindowOrientationAngle(M::Angle270);
    That changes the keyboard orientation correctly, however the actual dialog is still in landscape orientation.
    Is there a way to change the QDialog orientation?

    If not, would you suggest I create a QGraphicsView specifically just to pop up MDialog? I tried without it and got the following:
    Themedaemon replied with error packet:
    The registration packet must provide a name for the client

    So I am guessing that I need to call this under a QGraphicsView specifically.

    Thanks

  9. #9
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Text input in N9

    Hi,
    The N9 WM doesn't support RandR, which means you cannot use X11 to rotate your QWidgets, but you have to draw it rotated.
    To change QWidget orientation you can read this article: http://www.developer.nokia.com/Commu...d_applications
    Anyway basically you have to embedd QWidget in a QGraphicsView to achieve that.

    At this point I think you could use Meego touch or QML components (which are not deprecated).

    About the missing registration packet, I think this page should help you.
    http://harmattan-dev.nokia.com/docs/...g_support.html

  10. #10
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    67

    Re: Text input in N9

    Thanks again gnuton. This is getting very involved just for a simple text input... It seems to be that the most sensible route without starting to delve into the intricacies of meego touch is probably to learn some basic qml and rotate within the QML inside a QDeclarativeview. I will try this approach and report back my success or lack thereof.

    Quote Originally Posted by gnuton View Post
    To change QWidget orientation you can read this article: http://www.developer.nokia.com/Commu...d_applications
    At this point I think you could use Meego touch or QML components (which are not deprecated).
    I mentioned this in my initial post, but it explicitly states that it does not support QDialogs.

  11. #11
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Text input in N9

    QML is really easy to learn, so don't be afraid. A dialog in QML is just a Rectangle.
    To rotate the Rectangle you have to set the angle property

    Eg:
    Rectangle {
    id: myDialog
    angle: -90
    ...
    }

    BTW If you use plain QML you won't have the correct style, since plain QML has only primitives (Rectangles, TextEdit, TextInput and so on), not widgets.
    You can customize a pure QML UI as you wish, and acutally it's not difficult, but it involves a little bit more than using components.

    Other approach is to use Qt Components. Components are widget written in QML. Those have same look and feel of standard MeeGo widgets (the one you see in the meego touch lib).
    The problem with dialogs on meego is that meego dialogs are fullscreen semi-transparent widgets; so if you use MeeGo components you will have a completely black
    window with your content.
    To make the QWidget (QDeclarativeView ) translucent you need to set some attributes to the window; read this article for more info http://www.developer.nokia.com/Commu...arent_QML_Apps.
    The code I menthioned has not been actually tested on harmattan and I'm not sure if it works, but you can try and let me know/update the article.
    If you cannot achieve transparency then no problem if it's okay for you to show a black window as background of your dialog.

    Between Qt component and pure QML approach, I believe Components' one need much less code and work. Hence, I suggest you to use that one.
    In case you need help let me know.

    For specific issues with QML it's maybe worth to open new threads in the Qt/QtQuick forum that you can find here in developer.nokia.com.

    http://harmattan-dev.nokia.com/docs/...go-dialog.html

  12. #12
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    67

    Re: Text input in N9

    Success!

    There is a problem using the QML components though, using the TextField I get:
    Valid eglHandle received but not running with meego compatible graphicssystem.
    file:///usr/lib/qt4/imports/com/nokia/meego/TextField.qml:238:5: QML BorderImage: Failed to get image from provider: image://theme/meegotouch-textedit-background-selected

    I had to switch the graphicssystem to opengl using QApplication::setGraphicsSystem("opengl") for this application to work, otherwise there are problems with the opengl context being destroyed before the application is notified that it is going into the background causing other issues. I tried with the default graphics system and got a different error, but the same result.

    So I have proceeded using a normal TextInput, and this works quite well. There was another strange issue though which needed a workaround - using Text doesn't render and gives x server errors, however textinput does render - so for text labels I am using TextInput set to readonly.

    Also I have used the MInputMethodState::instance()->setActiveWindowOrientationAngle(M::Angle270) for the correct keyboard orientation.

    Finally this is working pretty decently and gives a similar experience to QDialog on Symbian. Very appreciative of everyone's help!

  13. #13
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Text input in N9

    Well done!
    MeeGo graphicssystem uses to destroy gl context every time apps is "minimized".
    IIRC this issue:
    "Failed to get image from provider: image://theme/meegotouch-textedit-background-selected" comes when you don't use the native graphics system, am I right?
    A possible way to work around this is to define a QImageProvider which provides that image. [1]

    Anyway, nice it works fine

    [1] http://doc.qt.nokia.com/4.7-snapshot...eprovider.html

  14. #14
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    67

    Re: Text input in N9

    Yes, the problem with the graphics context being destroyed when minimised was that this happened before my app got any notification (possibly in the middle of anything, I think, due to being in another thread/process?), so either I got errors or I had to check if my context had vanished every frame, which I still wasn't sure would be reliable. I don't know if it's changed with the new update.

    You're right that the image issue comes up with the non native system, but with the native system it also didn't work, although with a different error. It was something like "Couldn't create texture from shared pixmap" (Not exactly but from memory). Also, with the native system, there was some weird stuff with the QDeclarativeView, for example the background of the textinput was blue. I think maybe it would be fine if it was not a child of my main QWidget that is using EGL, maybe its own top level widget - it seems like there is a bit of a conflict there... but it works ok now for my purposes anyway.

Similar Threads

  1. Input text and soft key problem & predictive text - actionscript 2
    By kyazdani in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2011-11-05, 22:00
  2. Replies: 2
    Last Post: 2009-03-25, 00:58
  3. Can't switch numeric input to text input in RichTextEditor
    By mobilepig in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-01-03, 05:14
  4. Replies: 2
    Last Post: 2006-01-31, 11:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×