Project

General

Profile

Actions

Bug #6105

open

setfocus

Added by Bert Cuypers about 7 years ago. Updated about 7 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Target version:
Start date:
11/06/2017
Due date:
% Done:

0%

Estimated time:

Description

When multiple WLineEdit and WPushButton widgets are attached to a WTemplate, the setFocus property of the WLineEdit widgets does not seem to work. The last WLineEdit widget, as defined in the layout.xml file, gets the focus. This used to work correctly with Wt 3.3.8.


Files

ChangePasswordWidget.cpp (1.89 KB) ChangePasswordWidget.cpp Bert Cuypers, 11/16/2017 08:34 AM
ChangePasswordWidget.h (484 Bytes) ChangePasswordWidget.h Bert Cuypers, 11/16/2017 08:34 AM
Layout.xml (819 Bytes) Layout.xml Bert Cuypers, 11/16/2017 08:34 AM
Actions #1

Updated by Roel Standaert about 7 years ago

Could you maybe provide some example code demonstrating the issue? I can't seem to reproduce it with the latest master.

Actions #2

Updated by Roel Standaert about 7 years ago

  • Status changed from New to Feedback

Updated by Bert Cuypers about 7 years ago

Hi Roel, here you go. I call this widget for example from a (bootstrap) navbar on the right-hand side in a pop-up menu.

Actions #4

Updated by Bert Cuypers about 7 years ago

Hi Roel,

Were you able to reproduce this bug using the code I provided? I'm having this problem now with a couple of dialogs...

Thanks!

Best regards

Bert

Actions #5

Updated by Bert Cuypers about 7 years ago

Hi Roel,

I got it fixed! When i set autofocus(false) and then use the normal "setFocus()" on the first element, the focus is set correctly. Is there any explanation why this is the case for the bootstrap theme?

Best regards

Bert

Actions #6

Updated by Roel Standaert about 7 years ago

This is the case in general it seems. When autofocus is enabled, it will focus on the first child. However, when using a WTemplate, children() will return the widgets in it in order of their key. Because "confirmPassword" < "currentPassword", confirmPassword will be focused on instead. This wasn't the case in Wt 3, because in Wt 3 the widgets were returned in the order that they were bound. I'll see if something can be done about that, but with a WTemplate, it's not as simple to determine what is the real first widget.

Actions #7

Updated by Bert Cuypers about 7 years ago

Hi Roel, just as an idea: wouldn't it be interesting to make "setFocus" override the autofocus property? I didn't have any idea that autofocus was enabled by default, which made it difficult to find the problem...

Actions #8

Updated by Roel Standaert about 7 years ago

Yes, I did notice that it's not documented that it's enabled by default. It makes sense to me that setFocus should disable it, but I'm not sure that it will be straightforward to implement.

Actions #9

Updated by Bert Cuypers about 7 years ago

Okay, thanks for the explanation Roel!

Actions

Also available in: Atom PDF