JDK-8091976 : Expose TextInputControl undo(), redo(), canUndo(), canRedo() methods
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 7u40
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2012-11-29
  • Updated: 2023-08-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Blocks :  
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
TextInputControl provides undo/redo through keyboard shortcuts.
However it would be good to expose these capabilities through the API :
the application could use them when implementing its Undo/Redo menu items.

boolean TextInputControl.canUndo()
boolean TextInputControl.canRedo()
void TextInputControl.undo()
void TextInputControl.redo()

Comments
See workaround described for RT-36404.
31-03-2014

Another question is how to spec the undo/redo functionality. Specifically, when you call setText(), does this wipe out the history? Or does it just add to it? When do we clear the undo history?
18-01-2013

I think undo / redo methods is a no-brainer. It seems to fit in with cut(), copy(), and paste() methods quite nicely. The problem with canUndo and canRedo is that these methods need to be dynamic -- true properties. Because you probably want to add a listener to the property and respond to changes in the value. canUndo is kind of problematic in that case ("getCanUndo()" or "isCanUndo()" both sound weird), I might go with "undoable" and "isUndoable". But those are weird names too :-). Also, I need to see who is responsible for determining whether it can undo / redo. If it is the skin then there needs to be a means for updating the state on the TextInputControl.
17-01-2013

See also RT-9574. JavaFX controls could benefit from an action map framework like Swing has.
29-11-2012