Changing individual TextArea/TextEditor lines in Flex? - apache-flex

So for a summer project I am thinking of writing a colaborative code editing application in Flex. In order to do this I need to be able to modify individual lines or characters in a text area as different user's modify the same document.
I think I've heard of Flex 4 having support for text primitives but that is still in development. Is there any way to modify or get the individual lines in a text area?
Also if anyone could shed some light on how text areas/editors store and process the text it displays, this would be very helpful. I've been diving into the source code but am still struggling to wrap my head around it.
Thanks!

If you're willing to work with the beta, you can work with the stuff in flex 4 now:
http://opensource.adobe.com/wiki/display/flexsdk/Gumbo+Text+Primitives

I believe you can bind htmlText of a TextArea. It will dispatch a htmlTextChanged event when there is a change that you can respond to. I do not know if this will be comprehensive enough for what you are trying to accomplish (May be necessary to roll out a editor from scratch?).

Why don't you use the htmlText property, and add markup manually to the text string? That might be your simplest option. Otherwise, you can dig into the internal textfield property and monkey around with the selectionIndex properties and set the textFormat on the range. Look at the TextField / TextFormat stuff in the flash documentation.
Not sure exactly how to accomplish it via the TextArea, but I guarantee it will be frustrating...

Related

Is it possible to automatically format JavaFX HTMLEditor contents as I type?

Is it possible to apply automatic HTML formatting to text as it's typed into a JavaFX HTMLEditor?
Previously I achieved what I wanted via the RichTextFx class, but I wanted to see if it's possible via HTMLEditor as this is now standard to JavaFX.
The only way I can see so far is to get the HTML text, strip it of its tags, then apply my own tag formatting, then set the HTML text contents again. Although inefficient this would probably work for what I want, but having tried it the editor loses focus and requestFocus() doesn't focus, and even if it did I think I'd have to set the cursor position.
I suspect it is possible to do it as you describe, though it will be inefficient in the ways you have already identified.
Perhaps a better solution, assuming RichTextFX isn't an option, would be to roll your own solution using TextFlow and multiple Text nodes.
https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/text/TextFlow.html
That is essentially what RichTextFX is doing.

Where is a reference for the customizable stylesheet properties for Qt widgets?

I've been struggling with learning how to use stylesheets to customize the look of my widgets in Qt.
For example, after much effort, I just figured out that the name of the property that determines what color the text on a QComboBox drop-down menu is when it is mouse-over'd is selection-color, and the background color is selection-background-color. But most of that I discovered by random guess-and-check.
Where can I find documentation that will actually tell me these things so I don't have to guess? Does Qt follow some sort of standard naming convention?
http://doc.qt.nokia.com/latest/stylesheet-reference.html
http://doc.qt.io/qt-5/stylesheet-examples.html
The above link gives examples for pretty much every control. For the combobox it mentions the QAbstractItemView, and mentions that you need selection-background-color etc... to style it - with an example.
It doesn't always explain what each property does however, which is where the doc that baysmith linked to comes in.
So with these two documents together you should be in good shape.

How to display xmls in Flex?

I have XML pages with some defined structure , now using flex I want to display the content of these pages. The purpose of using Flex is to give better look.
If I can use something else which will provide a good UI to display then also its fine.
Please suggest.
you want to display the XML code??
read the xml file into a simple textarea and ready.
Damian
You could use an mx.controls.Tree and fill its dataProvider with your XML. It's an old component, sometimes buggy when you want to tweak it, but it provides a neat display of a tree. In addition you could use a textarea to display the node currently selected.

Does the Flex rich text control have any practical value?

Since the control emits bizzare non-standard HTML, I'm wondering if it has any practical value.
The control emits font tags!
How are others dealing with it? Do you do some sort of RegEx replace on the text?
Or am I missing something?
Does it have a value? Yes. Is it practical? That depends. How much work are you willing to do to get something useful out of it?
I had to use the RTC to create a chat window for a chat app that was built on Jabber. I wound up having to parse every line of every chat message, check its textwidth, GREP out the bogus HTML (TextFormat and Font tags) while leaving the styling tags (bold, italic, etc.) then shift it onto a queue that would scroll upwards as new messages were sent and received. I had to keep an onscreen buffer of 200 of these lines (taking care not to delete partial messages at the end of the queue). I also had to plot where the emoticons — :) ;) :-) and the like — were located, find out their exact locations, and then draw the emoticon images onto a sync-scrolled Canvas that exactly matched the position of the chat output window. All this while keeping the text selectable and letting people copy and paste it, complete with emoticon tokens that reverted to whatever text smiley upon pasting into the input field.
Was this a lot of work? You bet it was. Was the product ultimately useful? I like to think so. It was pretty cool, in fact. And as it was one of the first Flex projects I ever worked on, it taught me a lot.
Do I wish Adobe supported real, non-gimped HTML? Absolutely.
Short answer: Getting something out of the RTC is a bitch, but probably still faster than doing anything similarly useful in Java or C++. YMMV.

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