public class PStyledTextEventHandler extends PBasicInputEventHandler
Modifier and Type | Field and Description |
---|---|
protected PCanvas |
canvas
Canvas onto which this event handler is attached.
|
protected DocumentListener |
docListener
A listener that will handle programatic changes to the underlying
document and update the view accordingly.
|
protected PStyledText |
editedText
The Styled text being edited.
|
protected JTextComponent |
editor
Editor used to edit a PStyledText's content when it is in edit mode.
|
Constructor and Description |
---|
PStyledTextEventHandler(PCanvas canvas)
Basic constructor for PStyledTextEventHandler.
|
PStyledTextEventHandler(PCanvas canvas,
JTextComponent editor)
Constructor for PStyledTextEventHandler that allows an editor to be
specified.
|
Modifier and Type | Method and Description |
---|---|
protected JTextComponent |
createDefaultEditor()
Creates a default editor component to be used when editing a PStyledText
node.
|
protected DocumentListener |
createDocumentListener()
Returns a document listener that will reshape the editor whenever a
change occurs to its attached document.
|
PStyledText |
createText()
Creates a PStyledText instance and attaches a simple document to it.
|
void |
dispatchEventToEditor(PInputEvent event)
Intercepts Piccolo2D events and dispatches the underlying swing one to
the current editor.
|
protected void |
initEditor(JTextComponent newEditor)
Installs the editor onto the canvas.
|
void |
mousePressed(PInputEvent event)
A callback that is invoked any time the mouse is pressed on the canvas.
|
void |
reshapeEditor()
Adjusts the shape of the editor to fit the current document.
|
protected void |
reshapeEditorLater()
Sometimes we need to invoke this later because the document events seem
to get fired before the text is actually incorporated into the document.
|
void |
startEditing(PInputEvent event,
PStyledText text)
Begins editing the provided text node as a result of the provided event.
|
void |
stopEditing(PInputEvent event)
Stops editing the current text node.
|
acceptsEvent, getEventFilter, keyboardFocusGained, keyboardFocusLost, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, mouseWheelRotated, mouseWheelRotatedByBlock, paramString, processEvent, setEventFilter
protected PCanvas canvas
protected JTextComponent editor
protected DocumentListener docListener
protected PStyledText editedText
public PStyledTextEventHandler(PCanvas canvas)
canvas
- canvas to which this handler will be attachedpublic PStyledTextEventHandler(PCanvas canvas, JTextComponent editor)
canvas
- canvas to which this handler will be attachededitor
- component to display when editing a PStyledText nodeprotected void initEditor(JTextComponent newEditor)
newEditor
- component responsible for a PStyledText node while it is
being edited.protected JTextComponent createDefaultEditor()
protected DocumentListener createDocumentListener()
public PStyledText createText()
public void mousePressed(PInputEvent event)
mousePressed
in class PBasicInputEventHandler
event
- mouse click event that can be queriedpublic void startEditing(PInputEvent event, PStyledText text)
event
- the event responsible for starting the editingtext
- text node being editedpublic void stopEditing(PInputEvent event)
event
- the event responsible for stopping the editingpublic void dispatchEventToEditor(PInputEvent event)
event
- the swing event being interceptedpublic void reshapeEditor()
protected void reshapeEditorLater()
Copyright © 1995-2012 Piccolo2D. All Rights Reserved.