Home » Eclipse Projects » Remote Application Platform (RAP) » [Combo] Text Highlighting after SelectionChange by a Function
| | | | |
Re: [Combo] Text Highlighting after SelectionChange by a Function [message #1499649 is a reply to message #1497047] |
Fri, 05 December 2014 09:44 |
David Salomon Messages: 4 Registered: December 2014 |
Junior Member |
|
|
Hi again
I'm trying to disable the highlighting (both cases: select from list an select by code). There seems to be no simple way, isnt it?
EDIT: Meanwhile i found out, after i add a second Combo to my Snippet only one Text gets highlighted (marked).
/***/
public class BasicEntryPoint extends AbstractEntryPoint {
@Override
protected void createContents(Composite parent) {
parent.setLayout(new GridLayout(2, false));
final Combo combo = new Combo(parent, SWT.NONE);
combo.setItems(new String[]{"Car", "House", "Tree", "Shoe"});
combo.select(0);
final Combo combo2 = new Combo(parent, SWT.NONE);
combo2.setItems(new String[]{"Car", "House", "Tree", "Shoe"});
combo2.select(0);
Button button = new Button(parent, SWT.PUSH);
button.setText("Switch Selection");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = combo.getSelectionIndex();
combo2.select(index < 3 ? index + 1 : index - 3);
combo.select(index < 3 ? index + 1 : index - 3);
}
});
}
}
[Updated on: Fri, 05 December 2014 13:07] Report message to a moderator
|
|
|
Re: [Combo] Text Highlighting after SelectionChange by a Function [message #1567312 is a reply to message #1499649] |
Fri, 16 January 2015 09:23 |
Sebastian Eckey Messages: 1 Registered: January 2015 Location: Germany |
Junior Member |
|
|
Hello,
I am experiencing the same issue as described.
I tried the snipped posted by David and you can see the issue there.
For my tests I used RAP 2.3.1.
When you run it you see two combos. When you click on the combo itself and changes the selection, the text of your selection gets highlighted. No problem here.
But when you click the button, the selection of the combo gets changed from outside the combo. There is no focus involved.
Both combos get the same input by the button, the button is clicked by the mouse.
After the click was performed the focus remains at the button.
The issues:
- The text of the selection of combo2 is selected, eventho the selection of combo2 gets changed before the first combo. Why that?
- When you press space now, you will click the button, the selection gets changed again.
- When you type some text, it will change the text inside the combo.
It just doesn't feel right.
Then I play a little bit around.
Next to each combo I placed a new Text. When the button gets pressed they get the text for the combo via getText.
The result: Combo2, the third item counted from the right in a row of five, highlights the text. In my opinion this looks weird.
Then I called setEnabled(false) on each combo.
Now I am able to set two focuses.
I click on the textfield, focus gets transferred to the textfield, no problem.
Then I click on the text inside of one of the combos.
The text of the combo gets highlighted, but the focus remains at the textfield, seen by the blue shadow around it.
private class TestComposite extends Composite {
public TestComposite(final Composite parent) {
super(parent, SWT.NONE);
setLayout(new GridLayout(5, false));
final Combo combo = new Combo(this, SWT.NONE);
final Text text = new Text(this, SWT.BORDER);
final Combo combo2 = new Combo(this, SWT.NONE);
final Text text2 = new Text(this, SWT.BORDER);
final Button button = new Button(this, SWT.PUSH);
combo.setItems(new String[] { "Car", "House", "Tree", "Shoe" });
combo2.setItems(new String[] { "Car", "House", "Tree", "Shoe" });
combo.select(new Random().nextInt(4));
combo2.select(new Random().nextInt(4));
button.setText("Switch Selection");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = combo.getSelectionIndex();
combo2.select(index < 3 ? index + 1 : index - 3);
combo.select(index < 3 ? index + 1 : index - 3);
text.setText(combo.getText());
text2.setText(combo.getText());
combo.setEnabled(false);
combo2.setEnabled(false);
}
});
}
}
Thanks in advance
Best,
Sebastian
|
|
|
Goto Forum:
Current Time: Sat Apr 27 03:45:30 GMT 2024
Powered by FUDForum. Page generated in 0.03647 seconds
|