| Missing focusLost when keyboard-triggering default button [message #987400] |
Mon, 26 November 2012 08:32  |
Marco Missfeldt Messages: 5 Registered: November 2012 |
Junior Member |
|
|
I have a view with some controls and a default button, set by setDefaultButton(Button).
In SWT, when I press ENTER to trigger the default button, the focus changes to the default button before it is triggered. In RWT the focus doesn't change.
This only affects keyboard triggering. When I use the mouse to trigger the default button, the focus change occurs.
This is a big issue for us because we use the focus lost events on text controls to perceive content changes as a whole (and not on every single key press).
So the effect in RWT for example is when I enter a password and directly hit ENTER to trigger the Login-Button, the password input is not recognized because of the missing focus change. When I use the mouse instead everything is fine.
I wonder if nobody else has problems with this or am I missing an important point?
|
|
|
|
| Re: Missing focusLost when keyboard-triggering default button [message #987568 is a reply to message #987469] |
Tue, 27 November 2012 03:19   |
Marco Missfeldt Messages: 5 Registered: November 2012 |
Junior Member |
|
|
Hi Ivan,
I use RAP version 2.0.0-M3-20121112-1148.
Btw - I found a little workaround for this problem. If I check and transfer the focus in my Button-Listener, I am able to get the behaviour which is the standard in SWT - here the snippet:
// getControl() returns the Button
this.getControl().addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(final SelectionEvent e) {
// Workaround for RAP - ensure that the old control loses and the button gets the focus
if (!PvTButton.this.getControl().isFocusControl()) {
PvTButton.this.getControl().forceFocus();
}
... // calling some controller action
}
...
});
While this helps me for the moment I think there should be the same behaviour between RWT and SWT.
Best regards
Marco
[Updated on: Tue, 27 November 2012 03:24] Report message to a moderator
|
|
|
|
|
| Re: Missing focusLost when keyboard-triggering default button [message #987634 is a reply to message #987400] |
Tue, 27 November 2012 06:35   |
Thomas Schindl Messages: 4462 Registered: July 2009 |
Senior Member |
|
|
Just to make sure.
Have you tested this behavior on all SWT platforms? On Mac normally a
button can never receive focus so if you rely on this your application
it is broken on Mac OS-X as well!
In the RAP case the behavior you see might be a bug, on OS-X it is
desired, bottom line do not use focus-out, or explicitly sync your model
from the UI before you execute actions attached to the SWT buttons.
Tom
Am 26.11.12 14:36, schrieb Marco Missfeldt:
> I have a view with some controls and a default button, set by
> setDefaultButton(Button).
>
> In SWT, when I press ENTER to trigger the default button, the focus
> changes to the default button before it is triggered. In RWT the focus
> doesn't change.
>
> This only affects keyboard triggering. When I use the mouse to trigger
> the default button, the focus change occurs.
>
> This is a big issue for us because we use the focus lost events on text
> controls to perceive content changes as a whole (and not on every single
> key press).
>
> So the effect in RWT for example is when I enter a password and directly
> hit ENTER to trigger the Login-Button, the password input is not
> recognized because of the missing focus change. When I use the mouse
> instead everything is fine.
>
> I wonder if nobody else has problems with this or am I missing an
> important point?
|
|
|
| Re: Missing focusLost when keyboard-triggering default button [message #987639 is a reply to message #987634] |
Tue, 27 November 2012 07:05   |
Marco Missfeldt Messages: 5 Registered: November 2012 |
Junior Member |
|
|
Tom, we don't use Macs here, so I just can take Win-32 as the native comparison platform.
Your suggestion to explicitly sync view and model before action executing would be a technically valid option, but it would compromise the way our existing MVC architecture works (we also support Swing and other UI-Systems) and would lead to a number of difficulties concerning locality and contexts.
And still we would also need the focus-lost behaviour, because we want the new content to appear inside the model attribute just after it has been entered completely.
I really would love to have an alternative to focus-lost. In Swing you can use an InputVerifier as a good alternative, because it is only triggered after focus leaves, but in SWT the ModifyListener and VerifyListener both are triggered after each key typed, which would lead to far too many updates in our models.
Marco
[Updated on: Tue, 27 November 2012 07:06] Report message to a moderator
|
|
|
|
| Re: Missing focusLost when keyboard-triggering default button [message #987793 is a reply to message #987674] |
Wed, 28 November 2012 03:27  |
Marco Missfeldt Messages: 5 Registered: November 2012 |
Junior Member |
|
|
Hi Thomas,
this delayed observable would be no solution for us, only new complexity. As you wrote correctly, this would not free us from explicitely syncing. And even worse: As many of our customers are no high-performance writers, still various intermediate results would be written into our models - leading to misleading attribute validations in the worst cases.
You're right that we would have a problem on Mac-SWT, but this is not a platform we plan to use. And if we must, we still have Swing as a proven alternative. We mainly support SWT because of RAP - as we looked for an AJAX-Platform that fits nicely into our architecture. Of course it's a great bargain that native SWT works too.
Now for the conclusion: I still think it's right to see this issue as a bug, because RAP is not Mac and in RAP the button is capable of getting the focus. So it should do, as is the case on other SWT platforms with focussable buttons like Windows.
Marco
|
|
|
Powered by
FUDForum. Page generated in 0.01939 seconds