Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 156251 - Enter key does not cause data-binding to fire on a Text control
Summary: Enter key does not cause data-binding to fire on a Text control
Status: RESOLVED DUPLICATE of bug 156264
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-05 15:30 EDT by Andy Maleh CLA
Modified: 2006-09-06 08:52 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Maleh CLA 2006-09-05 15:30:52 EDT
This is related to Data-Binding Framework.

In an RCP project, I encountered a missing feature that my client wants. It is required for several screens that use data-binding to update calculations off of text control values.

The client wants calculations to get updated when hitting Enter or Carriage Return on a text control. Currently, they only get updated when tabbing off.

I implemented a fix in TextObservableValue by updating the keyListener code:

keyListener = new KeyListener() {
	public void keyPressed(KeyEvent e) {
		if (e.character == SWT.ESC && bufferedValue != null) {
			// Revert the value in the text field to the model value
			text.setText(bufferedValue);
		}
                // Begin new code
		String oldValue = bufferedValue;
		String newValue = text.getText();
		if (e.character == '\r' || e.character == '\n') {
			if (!newValue.equals(oldValue)) {
				fireValueChange(Diffs.createValueDiff(oldValue,
						newValue));
			}
			
		}
                // End new code
	}

	public void keyReleased(KeyEvent e) {
	}
};

I would like to contribute this fix, but first, I would like to get your opinion on how to generalize this solution. 
For example:
-Is it better to allow programmers to specify characters that fire-off data-binding events in a text control, or should we keep Enter and Carriage Return hard-coded?
-What other widgets need this fix/customization? For example, editable combos are another candidate for this fix.
-Is this already done elsewhere?

Thank you,

Andy
Comment 1 Boris Bokowski CLA 2006-09-06 08:52:40 EDT

*** This bug has been marked as a duplicate of 156264 ***