[fxruby-users] FXText undo functions? keysend of Ctrl + z?

Jeroen van der Zijp jeroen at fox-toolkit.org
Fri Mar 7 14:44:13 EST 2008


On Friday 07 March 2008, datatec wrote:
> 
> Sorry really new to Fox and FXruby in particular. So these may be extreemly
> dumb questions.
> 
> 
> Does FXText have a native undo/redo function?

It is intended that it could be hooked up to one; see Adie editor.

> I have written one from scrach for what I am doing but one exists, would
> really love to know how to use it.

OK, FXText [and some other widgets too, BTW], have been written to emit some
messages when changes are made to the contents by the user.

For example, FXText emits SEL_INSERTED, SEL_REPLACED, SEL_DELETED messages, which
reference a FXTextChange struct, which contains some information about the change
that just took place.

The typical thing to do is to stuff this information into a (subclass of) FXCommand,
which is then hung under FXUndoList.

Neat is, FXUndoList can be directly hooked up to FXMenuCommand or FXButton so that
there is no further glue needed between the GUI and this functionality.

In the case of Adie, these subclasses are called FXTextInsert, FXTextDelete, and
FXTextReplace. Each of these corresponds to one of the possible callback messages
from above.

Of course, you can write your own methods to handle these as well.  However, I
recommend intercepting the same messages since they're intended for this very
same purpose and its probably less work than intercepting all possible keystrokes
[plus, some text changes happen e.g. by means of drag and drop, and you wouldn't
know about these except via SEL_INSERTED, SEL_REPLACED, SEL_DELETED].



Hope this helps,

			Jeroen


More information about the fxruby-users mailing list