Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Disposal of used (Tree-)Editor edit-controls
Disposal of used (Tree-)Editor edit-controls [message #463181] Fri, 28 October 2005 16:00 Go to next message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
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 #463200 is a reply to message #463181] Sat, 29 October 2005 22:34 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 97
Registered: July 2009
Member
Did you test your method?
If it works, that will be better way doing it.
Note that snippets do not mean best ways doing things.
They are just examples!


"Adam Pordzik" <adresseverbummelt@gmx.de> wrote in message
news:djthv0$h5m$1@news.eclipse.org...
> 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 #463201 is a reply to message #463200] Sun, 30 October 2005 12:28 Go to previous messageGo to next message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
Joe Smith wrote:
> Did you test your method?
> If it works, that will be better way doing it.

More or less. Or: Yes, with some tricks at least on Win32. The edit
control (e.g Text) sometimes reappeared in upper-left corner from
nowhere, if I didn't set it explicitly hidden. Also, I played with
setControl( null, null ); But I didn't looked in TreeEdit's surces
yet.

And I have absolute no idea what will happen on other platforms.

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.

> Note that snippets do not mean best ways doing things.
> They are just examples!

Sure. But I just had to ask, because I can't see the reason.

A

--
Re: Disposal of used (Tree-)Editor edit-controls [message #463202 is a reply to message #463201] Sun, 30 October 2005 12:53 Go to previous message
Adam Pordzik is currently offline Adam PordzikFriend
Messages: 19
Registered: July 2009
Junior Member
> 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

--
Previous Topic:Radio button and wrapping label
Next Topic:Persistent Expanded Tree
Goto Forum:
  


Current Time: Thu Apr 25 08:27:35 GMT 2024

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

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

Back to the top