Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Tree CCombo KeyListener traverse problem swt 3.1.1
Tree CCombo KeyListener traverse problem swt 3.1.1 [message #462067] Wed, 05 October 2005 16:00 Go to next message
Eclipse UserFriend
Originally posted by: supplanter64.hotmail.com

I am creating a treetable using the new swt Tree.
In my Tree I am adding two CCombo editors to columns 2 and 3. If I add
keylisteners to these controls, traversal (TAB key) from the tree to the
control does not work and traversal from control to control does not work.
Basically nothing seems to have focus.

Bug?

I am using modify and key listeners to provide auto-complete functionality
to the combo boxes. As the user types, if the leading characters of an item
in the combo box's drop down list matches those that the user types, then
the word is completed with the part that they haven't typed is highlighted
(using setSelection(Point point)).

The keylistener simply sets a flag to tell modify not to do it's thing when
the backspace, delete, or ctrl-x keys are pressed, otherwise my routine in
the modify listener will autocomplete again after the highlighted selection
was removed. So it looks like backspace, delete, etc. have no effect.
Re: Tree CCombo KeyListener traverse problem swt 3.1.1 [message #462069 is a reply to message #462067] Wed, 05 October 2005 16:09 Go to previous message
James Cornett is currently offline James CornettFriend
Messages: 3
Registered: July 2009
Junior Member
Sorry about the name...
Newreader was not setup correctly.

Here my custom combo source:

public class CComboCustom extends Composite
{
CCombo combo;
private boolean skipAutoComplete = false;


public CComboCustom(Composite composite, int style) {
super(composite, SWT.NONE);
this.setLayout(new FillLayout());
combo = new CCombo(this, style);
combo.addModifyListener(new ComboModifyListener());
combo.addKeyListener(new ComboKeyListener());
combo.addMouseListener(new ComboMouseListener());
layout();
}

private class ComboMouseListener extends MouseAdapter
{
public void mouseDown(MouseEvent e)
{
skipAutoComplete = true;
}
}

private class ComboKeyListener implements KeyListener
{

public void keyPressed(KeyEvent e)
{
if (e.keyCode == SWT.BS ||
e.keyCode == SWT.DEL ||
(e.keyCode == 120 && e.stateMask == SWT.CONTROL)) {
skipAutoComplete = true;
}
else
skipAutoComplete = false;

}

public void keyReleased(KeyEvent e)
{
}

}

private class ComboModifyListener implements ModifyListener
{

public void modifyText(ModifyEvent e)
{
if (!skipAutoComplete) {
String text = combo.getText();

if (text == null || text.equals(""))
return;

String current = "";
String[] items = combo.getItems();
int caretPosition = combo.getSelection().x;
boolean found = false;

for (int i = 0; i < items.length && !found; i++) {
current = items[i];

if (current.toUpperCase().startsWith(text.toUpperCase())) {
skipAutoComplete = true;
combo.setText(current);
found = true;
}
}
if (found) {
combo.setSelection(new Point(caretPosition,256));
}
skipAutoComplete = false;
}
}
}

public CCombo getCombo()
{
return combo;
}

"Eclipse RCP News Server" <supplanter64@hotmail.com> wrote in message
news:di0ta7$8f4$1@news.eclipse.org...
>I am creating a treetable using the new swt Tree.
> In my Tree I am adding two CCombo editors to columns 2 and 3. If I add
> keylisteners to these controls, traversal (TAB key) from the tree to the
> control does not work and traversal from control to control does not work.
> Basically nothing seems to have focus.
>
> Bug?
>
> I am using modify and key listeners to provide auto-complete functionality
> to the combo boxes. As the user types, if the leading characters of an
> item in the combo box's drop down list matches those that the user types,
> then the word is completed with the part that they haven't typed is
> highlighted (using setSelection(Point point)).
>
> The keylistener simply sets a flag to tell modify not to do it's thing
> when the backspace, delete, or ctrl-x keys are pressed, otherwise my
> routine in the modify listener will autocomplete again after the
> highlighted selection was removed. So it looks like backspace, delete,
> etc. have no effect.
>
Previous Topic:Help with no more handles error
Next Topic:How to disable a MessageDialog
Goto Forum:
  


Current Time: Tue Apr 23 10:51:48 GMT 2024

Powered by FUDForum. Page generated in 0.03163 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top