Best solution for user inputs like text input - playn

I just wonder what will be the best solution for receiving text input from user in PlayN.
I didn't find anything that i can use to achieve this, i think that the best solution will be to render something like HTML inputs to write a text, but it will be not that simple because we need to be able to use in example virtual keyboard from android (on android platform) and regular keyboard on HTML backend. Even then i think it will be very difficult (or impossible) to evoke android keyboard in game...
I'm thinking about creating a widget in tripleplay UI library (because i will use it), but this will end with rendering virtual keyboard on screen for user inputs.. buttons from a-z etc...
I wonder is there any better solution for this, or i need to implement something like i wrote above (like tripleplay widget)?

There is already a Tripleplay widget for receiving text input called Field.
However, it is very primitive and does not yet work on mobile platforms (it will work on an Android device with a hardware keyboard). We need to provide an API in PlayN to display the virtual keyboard, but until then there's no way for it to trigger the display of the virtual keyboard.
I don't recommend using this for any substantial text input, however. It doesn't (and never will) support cut and paste, or language input methods, or anything of the other extremely complex features that users expect for text input.
I would like to add an API to PlayN like:
Keyboard.requestTextInput(String label, Callback<String> callback)
which would pop up the virtual keyboard, with an attached (native) text box, and allow the user to enter a single line of text using all of the machinery of the platform's native text entry support. This will allow them to cut-and-paste, and use language input methods, and provide an experience with which they are comfortable on the platform in question.
If your game needs more sophisticated text input (like a chat interface, or the ability to take pages of notes), you will probably have to create a separate interface for each platform that you wish to support, using native multiline text editing widgets and then "wire" those into your PlayN game. This will be more complicated than can be described in a simple SO answer, so you'll have to do some research and learn how PlayN manages the display on each of the backends that you wish to support.

Related

Should I use Qt Widgets or Qt Quick to develop a rich text editor?

I am new to Qt in general, and I have been playing with it to get to learn about it since I have to develop a very specific text editor.
I want to know if anyone could help me understand which one is better (or the most indicated) for the development of a rich text editor. I have worked before with C and C++ but Qt Widgets seems like a very step hill for the time being and I am completely new to javascript in general.
Some of the settings that I would need to implement on the text editor for better context are:
Look for the user to be always connected to internet.
Transfer and receive data from another program.
Grant read only to the opened files and then permission to write on them when a button is clicked.
Has to work on linux and windows.
Needs to look great.
My context:
So far I have done a few little applications and even a little rich text editor on Qt Widgets, but since I was having problems with the GUI implementation that I wanted, I started looking for a way to solve it and found that Qt Quick might be the solution.
I have been trying Qt Quick, and for now on looks great, but I do not know if it has the capabilities to do what I have explained before. Or if it is better to use one or another.
I decided to create a new post since the one that I found looking for something similar is from 2014.
Also, the text editor for now only needs to work on desktop, but in a future might be on other devices and embedded systems.

How to implement specific functionality in a custom text object in pyQt?

I need to implement a specific text object in QEdit PyQt. I need rich objects that will content special information, capture the keyboard arrow keys only when cursor text is on these objects. They need support selection and copy / paste operations also. Outside of them, the cursor must act as normal behavior. At this time, the object does not need to show images or svg etc. Is only for capture text cursor purposes and to store specific information related with the object.
I read that I can implement a customized text object with this example:
textobject.py
but the example does not contain information about implement new html tags, how to capture focus, etc.
My questions are:
How can I add a new html tag related with my custom object for loading and saving documents?
How can I detect when text cursor is on the custom object to modify keyboard cursor behavior?
PyQt documentation says:
"Copy and Paste operations ignore custom text objects."
So is no way to implement copy / paste functionality?
How can I access to my custom object content?
I want to have specifics methods to navigate within the information contained in the object. I could save this information in another object, but I need to synchronize the information with the cursor because a document can contain many of these objects.
Context for my application: I'm developping a very specific application for blind users. I am blind myself. I need to make very specifics customizations to the Richttext area for accessibility. The goal is to develop an accessible math equation editor. For this, I need to add support for mathMl tag. I will process mathMl content inside these tags in my custom object, this part is already implemented at basic level without using any GUI framework. At this time I don't need to show the equation in the screen, I let to screen readers interact with my editor via a COM object. At this time, the equation box is functional, but I need to integrate this functionality in a rich text area. the idea is, a document can contain N math expressions that can be read, modified and saved in a document.
I plan to implement accessibility for sighted people also in the equation editor, but it is beyond my skills and is not a priority right now.
Also I need to accessibilize tables in rich text area, currently tables are not accesible in QT. Then I think to extend qt table functionality. Style elements like headings etc, does not exist in pyQt. OK, you can write a paragraph with heading style, but screen readers can't detect it. So I need to develop this functionality. I could solve it with customized objects I think.
Currently it need to work in windows only. Maybe later I'll consider other platforms.
I started to program in pyQt yesterday, but I already read a lot of documentation. I wrote a basic rich text editor to test my requirements.
I already tried to implement this application with wxPython phoenix because I've been using WX for a long time. But I couldn't implement custom text objects and I didn't find documentation about it.
If pyQt is limited for my requirements, could you recoment another gui framework?
Y could consider another languages, I chose Python because Python has many math tools like sympy or numpy, and implement user scripting functionality in the app is very easy.
Sorry for my bad english.

Best widget for a chat session in Qt

I am implementing a Desktop Qt application which uses an XMPP library to chat. I am trying to find the best approach in terms of performance, easy to modify, add custom stuff (for instance, show a thumbnain if someone sends me an image)...
I would like to know which approach do you think is the best:
- Each element as a layout or widget and add them one by one (it seems to be slow)
- ListWidget items overloading paint event (problem: don't know item height before painting)
- Use a rich text widget and build the chat as a HTML page (didn't tried it yet)
- ??
Best regards,
QListView would be good for simple IRC chat. If you are planning to implement some advanced text styling (different fonts, etc.) or images (like you said) WebView is the way to go. Additionally, much simpler way than QListView.
There's even an example Qt Google Chat project which uses QtWebKit: http://harmattan-dev.nokia.com/docs/library/html/qt4/webkit-googlechat.html
I would go for QListView with model attached and custom delegates etc..

How to make own input method in Qt application?

I would like to make an input method which is used only for Qt desktop application.
It like Chinese(Pinyin) input method in windows. Include script processing, rendering of words.
As it includes rendering of words, it can't be created with Keyboard Layout.
More over, when built-in with application, it can be use cross over other platform.
But, It not like on-screen keyboard.
Thanks for all
The Qt way to implement this is to provide an input method plugin, see general plugin development docs and the input method specific base class.
With this you should be able to implement your own input method. Stuff like script processing and rendering is then up to your own plugin.

Using QT to build a WYSIWYG Editor for a Custom Markup Language

I'm new to QT, and am trying to figure out the best means of creating a WYSIWYG editor widget for a custom markup language that displays simple text, images, and links. I need to be able to propagate changes from the WYSIWYG editor to the custom markup representation.
As a concrete example of the problem domain, imagine that the custom markup might have a "player" tag which contains a player name and a team name. The markup could look like this:
Last week, <player id="1234"><name>Aaron Rodgers</name><team>Packers</team></player> threw a pass.
This text would display in the editor as:
Last week, Aaron Rodgers of the Packers threw a pass.
The player name and the team name would be editable directly within the editor in standard WYSIWYG fashion, so that my users do not have to learn any markup. Also, when the player name is moused-over, a details pop-up will appear about that player, and similarly for the team.
With that long introduction, I'm trying to figure out where to start with QT. It seems that the most logical option would be the Rich Text API using a QTextDocument. This approach seems less than ideal given the limitations of a QTextDocument:
I can't figure out how to capture navigation events from clicking on links.
Following links on click seems to only be enabled when the QTextEdit is readonly.
Custom objects that implement QTextObjectInterface are ignored in copy-and-paste operations
Any HTML-based markup that is passed to it as Rich Text is retranslated into a series of span tags and lots of other junk, making it extremely difficult to propagate changes from the editor back to the original custom markup.
A second option appears to be QWebKit, which allows for live editing of HTML5 markup, so I could specify a two-way translation between the custom markup and HTML5. I'm not clear on how one would propagate changes from the editor back to the original markup in real-time without re-translating the entire document on every text change. The QWebKit solutions looks like awfully bulky to me (Learning WebKit along with QT) to what should be a relatively simple problem.
I have also considered implementing the WYSIWYG with a custom class using native QT containers, labels, images, and other widgets manually. This seems like the most flexible approach, and the one most likely not to run into unresolvable problems. However, I'm pretty sure that implementing all the details of a normal text editor (selecting text, font changes, cut-and-paste support, undo/redo, dragging of objects, cursor placement, etc.) will be incredibly time consuming.
So, finally, my question: are there any QT gurus out there with some advice on where to start with this sort of project?
BTW, I am using QT because the application is a desktop application that needs platform independence.
Given that I got no advice here, I decided to go with the QTextEdit approach, although I'm actually using a QTextBrowser that is set to be editable so that I can capture link navigation events. I will be using QTextCharFormat's with the link names set to unique identifiers in order to convert from the QTextEdit back to the custom markup. The QTextEdit supports images already, so I won't have to deal with those.
I think I will hit the biggest roadblocks with the fact that I need to be able to insert/grow/shrink tables whose cells can have Excel-style functionality. I have not yet figured that whole process out.

Resources