views:

1080

answers:

3

I'm having trouble finding any resource for adding ctrl-z undo capability to a Flex RichTextEditor control (a lack it apparently shares with other Flex text controls). I'm baffled that it's not in the native forms because it's such a fundamental capability, available in even standard browser text controls I believe.

Any mention of this issue on the Flex sites (there are several) conflict; one says the issue is "Closed" and the resolution is "External" (whatever that means).

Does anyone have any insight to offer? I've got an app the heavily requires extensive text editing. Flex in general works nicely, but this trivial lack is just about fatal, as anyone would imagine.

+1  A: 

Flex 3 controls do not natively support undo/redo. Here are a couple of libraries that may be of interest to you:

dirkgently
Have you used either of them? I'm a little concerned that one is as3 with no mention of flex, and the other's example app is a calculator not a text control.
le dorfier
No, I haven't. Why does it matter if it is in AS3? AS3 controls mix perfectly well with Flex. Check out the non-Cairngorm fork of the former.
dirkgently
I agree with dirkgently, I've used AS3 language libs with no problems in Flex (and in Flash, too).
Yar
AS3 controls? I'm not familiar with those. Is there anything equivalent to the RichTextEditor? I have no reluctance to use AS3 wherever I can. But this is so reinventing the wheel (and only because there's chip in one spoke of a very satisfactory wheel).
le dorfier
MXML is converted into AS3 which is further compiled to generate object code. Any MXML control can be written in AS3 (and used, if properly written, from within MXML).
dirkgently
+1  A: 

I've read elsewhere -- in fact, in the answers to one of my questions on SO -- that the issue is not going to be resolved in Flex 3. Which seems to be correct since we are in 3.2 or maybe even beyond that, and there's no undo in sight.

I was brave/stupid enough to implement an undo-redo in this component myself. At that time I was working on Windows. Now I'm on OSX and I realize just how non-cross-platform my solution is. The very statement of the problem (adding ctrl-z undo capability) is a large part of the problem (OSX has control AND this Apple key thing). Now I have to check how much work it would be to make the thing cross-platform... could be trivial.

By amazing coincidence, just today I've been thinking about NOT using the RichTextEditor but rather something external (FckEditor comes to mind) because the RTE leaves so much to be desired (hence I arrived at your question). I've worked with the RTE a ton and gotten it to do a lot of what I want, but I still wonder why they didn't "finish" this component...

Yar
Interesting. I've considered using pure javascript libraries. But wouldn't FckEditor etc. likely be letting the browser textbox it presumably subclasses handle basic keystroke functionality (e.g. cut/paste/undo/redo)? There's no plug-compatible replacement for browser controls in flash, is there?
le dorfier
Yes, FckEditor et. al. let the browser handle the stuff like undo and redo and all that. In AIR, you can use the HTML control (whatever it's called) to get the editor INSIDE the SWF, but in Flex/Flash, you would have to put it outside and talk to it using ExternalInterface (at least that's my idea). Not sure if I'm answering your comment...?
Yar
Today I tossed out all of my code and implemented the Flight Framework thing suggested below and... no way. Apparently I'll have to do this myself and keep going with my UndoStack. The reason is that the RTE is complicated and we want undo and redo for EVERY aspect of it, not just keystrokes. Plus, the Flight thing doesn't work well with complex(ly) formatted RTE contents.
Yar
+2  A: 

An example using the Flight Framework to easily implement undo/redo can be found here: http://www.xtyler.com/code/163

Sophistifunk
This is fascinating. Have you tried this? Are the undo and redo exposed to attach, for instance, buttons to them?
Yar
I haven't tried it, it's just coincidence I came across it a couple of day ago so it was fresh in my mind. But it's based on Flight's history system, so exposing buttons should be a doddle I imagine.
Sophistifunk