Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Undo on Text widgets
Undo on Text widgets [message #466408] Tue, 10 January 2006 11:51 Go to next message
Guido Kuepper is currently offline Guido KuepperFriend
Messages: 17
Registered: July 2009
Junior Member
Hi NG,

I'd like to implement custom undo support on SWT Text widgets. I already
thought about handling all possible events, but I think this is to be
considered awful. Also it is necessary to remove OS native undo of the
widget by pressing e.g. CTRL-Z on Windows.

Any Idea?

Mit freundlichen Gruessen / With best
regards


--
Dipl.-Ing. Guido Küpper


DSA Daten- und Systemtechnik GmbH
Pascalstraße 28
D-52076 Aachen
Germany

Phone: +49 (0) 2408 9492- 681
Fax: +49 (0) 2408 9492- 92
E-mail: Guido.Kuepper@dsa-ac.de
Internet: www.dsa.de
Re: Undo on Text widgets [message #466508 is a reply to message #466408] Tue, 10 January 2006 18:50 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Rather than handling all possible events, you should handle the SWT.Modify
event which is sent regardless of what action modified the text in the
widget.

To override the Ctrl-Z behaviour you need to define a Ctrl-Z accelerator.
Accelerators take precedence over the native widget commands. See:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet29.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup

Note if you are doing this inside Eclipse, defining an accelerator is not
the way to go - you must define an Action with a keyboard shortcut. Also,
Eclipse has its own Undo mechanism which you should look into.

"Guido K
Re: Undo on Text widgets [message #466545 is a reply to message #466508] Wed, 11 January 2006 11:43 Go to previous messageGo to next message
Guido Kuepper is currently offline Guido KuepperFriend
Messages: 17
Registered: July 2009
Junior Member
Veronika Irvine schrieb:
> Rather than handling all possible events, you should handle the SWT.Modify
> event which is sent regardless of what action modified the text in the
> widget.
>

Sounds interesting, but when is SWT.Modify fired? I do not like a
behaviour which generates a command on any key stroke. I'm thinking of
somethink like Eclipse editor behaviour which seems to have a timeout to
group some keystrokes in a certain time slot as one command. Does
handling SWT.Modify do this for me or do I have to look at event time
and decide on my own what to do ?

> Also,
> Eclipse has its own Undo mechanism which you should look into.
>
That's exactly the thing which takes too much time at the moment. Could
you please provide a hint where to look?
Sorry, always the same, other project tasks prevent me from looking
deeply into eclipse sources, although I'd like to do this.

Thanks in advance

Guido
Re: Undo on Text widgets [message #466553 is a reply to message #466545] Wed, 11 January 2006 15:06 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
SWT.Modify is fired on every key stroke - it also is fired for cut or paste
from a menu or accelerator or when the application calls setText().
Basically anything tha tcan modify the text. You would need to add your
timer if that was too frequently.

For information on the Undo mechanism of eclipse, you need to ask in the
eclipse.platform newsgroup. It is not an SWT feature but an eclipse UI
feature.
Previous Topic:Printing a Table
Next Topic:DropTargetAdapter.dragOver
Goto Forum:
  


Current Time: Sat Apr 27 05:05:15 GMT 2024

Powered by FUDForum. Page generated in 0.02866 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top