Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Simulating some Combo behavior for Text
Simulating some Combo behavior for Text [message #631631] Fri, 08 October 2010 09:06 Go to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On OS Windows systems, the Combo widget
marks the current text, when entering it
even with a click.

I want to realize a similar behavior for
text widgets. I could solve part of the problem
by adding a FocusListener like this

myText.addFocusListener(new FocusAdapter() {

@Override
public void focusGained(FocusEvent e) {
myText.selectAll();
}

});

This ensures that the text is selected when "tabbing" through all the
widgets within my composite. But it does not ensure that the text
becomes selected, when entering the widget *via* a mouse click,
which is something the Combo does on those systems.

Since I can observe that my focus observer is enetered even in
these situations, the reason could be that the mouse click
*follows* the focus enter event and does immediately "destroy" the just
realized selection.

Any ideas how to possibly realize the wanted behaviour preferrably via
the official API?

Thanks & Greetings from Bremen,

Daniel Krügler
Re: Simulating some Combo behavior for Text [message #631632 is a reply to message #631631] Fri, 08 October 2010 09:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
delay it with asyncExec?

Tom

Am 08.10.10 11:06, schrieb Daniel Krügler:
> On OS Windows systems, the Combo widget
> marks the current text, when entering it
> even with a click.
>
> I want to realize a similar behavior for
> text widgets. I could solve part of the problem
> by adding a FocusListener like this
>
> myText.addFocusListener(new FocusAdapter() {
>
> @Override
> public void focusGained(FocusEvent e) {
> myText.selectAll();
> }
>
> });
>
> This ensures that the text is selected when "tabbing" through all the
> widgets within my composite. But it does not ensure that the text
> becomes selected, when entering the widget *via* a mouse click,
> which is something the Combo does on those systems.
>
> Since I can observe that my focus observer is enetered even in
> these situations, the reason could be that the mouse click
> *follows* the focus enter event and does immediately "destroy" the just
> realized selection.
>
> Any ideas how to possibly realize the wanted behaviour preferrably via
> the official API?
>
> Thanks & Greetings from Bremen,
>
> Daniel Krügler
Re: Simulating some Combo behavior for Text [message #631675 is a reply to message #631632] Fri, 08 October 2010 12:36 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 08.10.2010 11:09, Tom Schindl wrote:
> delay it with asyncExec?

That is a good suggestion, Tom. It seems to
mimic the behaviour in a reasoanble way (In
some situations the selection is incomplete,
i.e. only the characters "before" the mouse
click position are selected), I think I
can live with that state.

Thanks very much,

- Daniel
Previous Topic:Close context menu when mouse is not hovering it
Next Topic:Tree selection rendering questions
Goto Forum:
  


Current Time: Fri Mar 29 09:01:32 GMT 2024

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

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

Back to the top