Disposal of used (Tree-)Editor edit-controls [message #463181] |
Fri, 28 October 2005 12:00  |
Eclipse User |
|
|
|
Hello,
I don't understand, why Snippet111 and in code JavaDoc for TreeEditor
disposes the used Text Controls on every Listeners invocation.
Why don't just Listen for SWT.FocusOut on Text, saving the result,
setVisible(false) and reusing the same Text control for next action, by
setting again its content with .setText() and just .setEditor() once
again?
A
--
|
|
|
|
|
Re: Disposal of used (Tree-)Editor edit-controls [message #463202 is a reply to message #463201] |
Sun, 30 October 2005 07:53  |
Eclipse User |
|
|
|
> Moreover, -I cant figure out why- the SWT-SocusOut Listener was not
> called for Text, so the Control keeps visible and I had to focus
> it again by mouse and leave it again. But I guess this is due an
> other issue.
P.S. I faced this is only with Combo. Text works fine. Would be nice if anybody can
confirm this as "working" on other platforms.
final TreeEditor treeEditor = new TreeEditor (tree);
treeEditor.minimumWidth = 100;
treeEditor.minimumHeight = tree.getItemHeight();
treeEditor.horizontalAlignment = SWT.LEFT;
treeEditor.grabHorizontal = false;
final Text treeText = new Text (tree, SWT.BORDER);
class TreeEditHandler implements Listener {
public void handleEvent( Event e ) {
TreeItem titi;
if( e.type == SWT.KeyDown && e.keyCode == SWT.F2 ) {
titi = tree.getSelection()[0];
} else if( e.type == SWT.DefaultSelection || e.type == SWT.Selection ) {
titi = (TreeItem)e.item;
} else {
return;
}
treeText.setText( titi.getText() );
treeText.selectAll();
treeEditor.setEditor(treeText, titi);
treeText.setFocus();
}
}
treeText.addListener (SWT.FocusOut, new Listener () {
public void handleEvent( Event event ) {
treeEditor.getItem().setText(((Text)event.widget).getText()) ;
((Control)event.widget).setVisible( false );
treeEditor.setEditor( null, null );
}
});
tree.addListener( SWT.KeyDown, new TreeEditHandler() );
tree.addListener( SWT.Selection, new TreeEditHandler() );
A
--
|
|
|
Powered by
FUDForum. Page generated in 0.04308 seconds