Skip to main content

Annoying focus behavior

7 replies [Last post]
Anonymous

Hi Shai,

I have a question / request:

When I have a list and above the list some focussable Labels in a Form.
When navigating through those elements I would expect the focus to move
continously first throug the labels at the top then through the list. I
set the list to FIXED_NONE

However with LWUIT - as far as I understand - focus is iterating either
within the list, or between list as a whole and the labels. So when I
see the form I have - as expected - my first Label in the form focussed
BUT also (visually painted) focus on the first element of the list.

So when I navigate down, I get into the list and then there is only one
focus visually painted that of the list. Trouble of course reoccurs when
I reach the end of the list as focus moves out of the List and starts
again at the top. Again 2 elements are then visually focussed: the last
element of the list, as well as the first Label - *very* confusing for
the user.

Hope you can tell me that I did something wrong here.

Rgds Ben

[att1.html]
[focus_problem.png]
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
saturon

This is still not clear to me, its not really working.

rgds ben
----Original Message-----
From: saturon [mailto:netbeans@vtxfree.ch]
Sent: Sonntag, 29. März 2009 19:26
To: users@lwuit.dev.java.net
Subject: RE: Annoying focus behavior

Thanks,

I feel a bit embarassed, but how do you do the deselection of list
items? i have a focus component with some transparency and tried setting
the focus of my renderer in the getListCellRendererComponent

if( isSelected&&list.hasFocus()) {
myFocus=focus;
}
else {
myFocus=noFocus;
}

focus / noFocus being lables returned in the getListFocusComponent which
was not working - focus within list flashes and not correctly draws
first element, and also focus is not hidden when list is not focussed -
and must be obviously not correct. I tried a few also a few other
variants but no luck.

Thanks Ben

------------------------------------------------------------------------
---

-----Original Message-----
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM]
Sent: Sonntag, 29. März 2009 08:27
To: users@lwuit.dev.java.net
Subject: Re: Annoying focus behavior

Hi,
the issue relates to selection in a list which is a completely separate
notion from focus although both are often mixed (such is the case for
you).

You can align selection and focus by placing a focus listener on the
form and updating selection to the right offset (0 or model.getSize() -
1) based on the last focused component before the list was selected.

The correct way to hide selection is to build a renderer that defines
isSelected based on the focus state of the list (this is discussed
frequently). Returning null from focus component will disable list
animation which might not be what you want...

Hi Shai,

I have a question / request:

When I have a list and above the list some focussable Labels in a Form.
When navigating through those elements I would expect the focus to move
continously first throug the labels at the top then through the list. I
set the list to FIXED_NONE

However with LWUIT - as far as I understand - focus is iterating either
within the list, or between list as a whole and the labels. So when I
see the form I have - as expected - my first Label in the form focussed
BUT also (visually painted) focus on the first element of the list.

So when I navigate down, I get into the list and then there is only one
focus visually painted that of the list. Trouble of course reoccurs when
I reach the end of the list as focus moves out of the List and starts
again at the top. Again 2 elements are then visually focussed: the last
element of the list, as well as the first Label - *very* confusing for
the user.

Hope you can tell me that I did something wrong here.

Rgds Ben
<<...>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

Shai Almog
http://lwuit.blogspot.com/
https://lwuit.dev.java.net/faq.html

[att1.html]

Shai Almog

[att1.html]

Shai Almog

Hi,
the issue relates to selection in a list which is a completely
separate notion from focus although both are often mixed (such is the
case for you).

You can align selection and focus by placing a focus listener on the
form and updating selection to the right offset (0 or model.getSize()
- 1) based on the last focused component before the list was selected.

The correct way to hide selection is to build a renderer that defines
isSelected based on the focus state of the list (this is discussed
frequently). Returning null from focus component will disable list
animation which might not be what you want...

> Hi Shai,
>
> I have a question / request:
>
> When I have a list and above the list some focussable Labels in a
> Form. When navigating through those elements I would expect the
> focus to move continously first throug the labels at the top then
> through the list. I set the list to FIXED_NONE
>
> However with LWUIT - as far as I understand - focus is iterating
> either within the list, or between list as a whole and the labels.
> So when I see the form I have - as expected - my first Label in the
> form focussed BUT also (visually painted) focus on the first
> element of the list.
>
> So when I navigate down, I get into the list and then there is only
> one focus visually painted that of the list. Trouble of course
> reoccurs when I reach the end of the list as focus moves out of the
> List and starts again at the top. Again 2 elements are then
> visually focussed: the last element of the list, as well as the
> first Label - *very* confusing for the user.
>
>
> Hope you can tell me that I did something wrong here.
>
> Rgds Ben
> <<...>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net

Shai Almog
http://lwuit.blogspot.com/
https://lwuit.dev.java.net/faq.html

[att1.html]

saturon

Thanks,

I feel a bit embarassed, but how do you do the deselection of list
items? i have a focus component with some transparency and tried setting
the focus of my renderer in the getListCellRendererComponent

if( isSelected&&list.hasFocus()) {
myFocus=focus;
}
else {
myFocus=noFocus;
}

focus / noFocus being lables returned in the getListFocusComponent which
was not working - focus within list flashes and not correctly draws
first element, and also focus is not hidden when list is not focussed -
and must be obviously not correct. I tried a few also a few other
variants but no luck.

Thanks Ben

------------------------------------------------------------------------
---

-----Original Message-----
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM]
Sent: Sonntag, 29. März 2009 08:27
To: users@lwuit.dev.java.net
Subject: Re: Annoying focus behavior

Hi,
the issue relates to selection in a list which is a completely separate
notion from focus although both are often mixed (such is the case for
you).

You can align selection and focus by placing a focus listener on the
form and updating selection to the right offset (0 or model.getSize() -
1) based on the last focused component before the list was selected.

The correct way to hide selection is to build a renderer that defines
isSelected based on the focus state of the list (this is discussed
frequently). Returning null from focus component will disable list
animation which might not be what you want...

Hi Shai,

I have a question / request:

When I have a list and above the list some focussable Labels in a Form.
When navigating through those elements I would expect the focus to move
continously first throug the labels at the top then through the list. I
set the list to FIXED_NONE

However with LWUIT - as far as I understand - focus is iterating either
within the list, or between list as a whole and the labels. So when I
see the form I have - as expected - my first Label in the form focussed
BUT also (visually painted) focus on the first element of the list.

So when I navigate down, I get into the list and then there is only one
focus visually painted that of the list. Trouble of course reoccurs when
I reach the end of the list as focus moves out of the List and starts
again at the top. Again 2 elements are then visually focussed: the last
element of the list, as well as the first Label - *very* confusing for
the user.

Hope you can tell me that I did something wrong here.

Rgds Ben
<<...>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

Shai Almog
http://lwuit.blogspot.com/
https://lwuit.dev.java.net/faq.html

[att1.html]

benefiz
Offline
Joined: 2008-10-29
Points: 0

Hey,

i think was Shai suggested was to track which component was focused before your list got focus.

[code]

// within form that implements FocusListener

Label firstLabel = new Label("First label");
Label otherLabel = new Label("Other label");
//...
Label lastLabel = new Label("Last label");
List list = new List(yourModel);

firstLabel.addFocusListener(this);
otherLabel.addFocusListener(this);
//...
lastLabel.addFocusListener(this);
list.addFocusListener(this);

yourForm.addComponent(firstLabel);
yourForm.addComponent(otherLabel);
//...
yourForm.addComponent(lastLabel);
yourForm.addComponent(list);

//...

public void focusGained(Component component) {
if (component == this.list) {
if (this.lastFocusedComponent == firstLabel)
this.list.setSelectedIndex(yourModel.getSize() - 1)
else if (this.lastFocusedComponent == lastLabel)
this.list.setSelectedIndex(0)
}
}

public void focusLost(Component component) {
this.lastFocusedComponent = component;
}
[/code]

Greetings
Ben

benefiz
Offline
Joined: 2008-10-29
Points: 0

I am not shai, but maybe i can help you as well.

Your ListCellRenderer must return null for the list focus component if the list itself has no focus. So you must override getListFocusComponent, e.g.

[code]
public Component getListFocusComponent(List aList) {

if (aList != null && !aList.hasFocus())
return null;

return [whateveryouwantelse];
}
[/code]

saturon

Thanks,

that did solve the behavior that 2 comonents are focussed. Now the
problem is with cycling: When I scroll down and up just to the end and
top, all works as expected.

Problem occurs however after I scroll over the last list-element and the
first label in the form gets the focus. Then after the labels on the top
of the form are focussed during the scrolling correctly, when I should
enter the list again instead of the first the last (?) list-element gets
focussed.

Similar when scrolling over the top instead of the last
list-element(restarting from the bottom) the first list-element gets
focussed.

I guess this has to do with the list set to FIXED_NONE and not to
FIXED_NONE_CYCLIC. Setting it to FIXED_NONE_CYCLIC is no option, because
I do not want the list itself to cycle but the whole form.

Any ideas?

-----Original Message-----
From: lwuit-users@mobileandembedded.org
[mailto:lwuit-users@mobileandembedded.org]
Sent: Freitag, 27. März 2009 10:54
To: users@lwuit.dev.java.net
Subject: Re: Annoying focus behavior

I am not shai, but maybe i can help you as well.

Your ListCellRenderer must return null for the list focus component if
the list itself has no focus. So you must override
getListFocusComponent, e.g.

[code]
public Component getListFocusComponent(List aList) {

if (aList != null && !aList.hasFocus())
return null;

return [whateveryouwantelse];
}
[/code]
[Message sent by forum member 'benefiz' (benefiz)]

http://forums.java.net/jive/thread.jspa?messageID=339294

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net