Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 107 additions & 14 deletions 121 core/src/processing/core/PApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,15 @@
import processing.data.*;
import processing.event.*;
import processing.event.Event;
import processing.event.KeyEvent;
import processing.event.MouseEvent;
import processing.opengl.*;

import java.applet.*;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.*;
import java.awt.font.TextHitInfo;
import java.awt.im.InputMethodRequests;
import java.awt.image.*;
import java.io.*;
import java.lang.reflect.*;
Expand Down Expand Up @@ -158,7 +150,8 @@
*/
public class PApplet extends Applet
implements PConstants, Runnable,
MouseListener, MouseWheelListener, MouseMotionListener, KeyListener, FocusListener
MouseListener, MouseWheelListener, MouseMotionListener, KeyListener, FocusListener,
InputMethodListener, InputMethodRequests
{
/**
* Full name of the Java version (i.e. 1.5.0_11).
Expand Down Expand Up @@ -703,6 +696,31 @@ static public class RendererChangeException extends RuntimeException { }
*/
public boolean focused = false;

/**
* ( begin auto-generated from committedText.xml )
*
* The String system variable <b>committedText</b> is committed text.
*
* ( end auto-generated )
* @webref input:inputmethod
* @see PApplet#committedText
* @see PApplet#composedText
* @see PApplet#inputMethodTextChanged()
*/
public String committedText;
/**
* ( begin auto-generated from committedText.xml )
*
* The String system variable <b>committedText</b> is composed text.
*
* ( end auto-generated )
* @webref input:inputmethod
* @see PApplet#committedText
* @see PApplet#composedText
* @see PApplet#inputMethodTextChanged()
*/
public String composedText;

/**
* Confirms if a Processing program is running inside a web browser. This
* variable is "true" if the program is online and "false" if not.
Expand Down Expand Up @@ -2545,6 +2563,8 @@ public void addListeners(Component comp) {
comp.addMouseMotionListener(this);
comp.addKeyListener(this);
comp.addFocusListener(this);
comp.enableInputMethods(true);
comp.addInputMethodListener(this);

// canvas.addComponentListener(new ComponentAdapter() {
// public void componentResized(ComponentEvent e) {
Expand All @@ -2569,6 +2589,8 @@ public void removeListeners(Component comp) {
comp.removeMouseMotionListener(this);
comp.removeKeyListener(this);
comp.removeFocusListener(this);
comp.enableInputMethods(false);
comp.removeInputMethodListener(this);
}


Expand Down Expand Up @@ -3498,6 +3520,77 @@ public void focusLost(FocusEvent e) {
focusLost();
}

/////////////////////////////////////////////////////////////
// TODO : write javadoc.
// Input Method(Multi-language) support
// InputMethodListener, InputMethodRequests
public void inputMethodTextChanged() {
}

public void inputMethodTextChanged(InputMethodEvent event) {
int committedCharacterCount = event.getCommittedCharacterCount();
AttributedCharacterIterator text = event.getText();

if (text != null) {
StringBuilder committedTextBuilder = new StringBuilder();
int toCopy = committedCharacterCount;
char c = text.first();
while (toCopy-- > 0) {
committedTextBuilder.append(c);
c = text.next();
}
committedText = committedTextBuilder.toString();
composedText = String.valueOf(c);
}
if(event.getCaret() == null) {
composedText = "";
}
event.consume();

this.inputMethodTextChanged();
}

public void caretPositionChanged(InputMethodEvent event) {
}

public InputMethodRequests getInputMethodRequests() {
return this;
}

@Override
public Rectangle getTextLocation(TextHitInfo offset) {
return null;
}

@Override
public TextHitInfo getLocationOffset(int x, int y) {
return null;
}

@Override
public int getInsertPositionOffset() {
return 0;
}

@Override
public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, AttributedCharacterIterator.Attribute[] attributes) {
return null;
}

@Override
public int getCommittedTextLength() {
return 0;
}

@Override
public AttributedCharacterIterator cancelLatestCommittedText(AttributedCharacterIterator.Attribute[] attributes) {
return null;
}

@Override
public AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes) {
return null;
}

//////////////////////////////////////////////////////////////

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.