Bug #6105
opensetfocus
0%
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
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.
Updated by Bert Cuypers about 7 years ago
- File ChangePasswordWidget.cpp ChangePasswordWidget.cpp added
- File ChangePasswordWidget.h ChangePasswordWidget.h added
- File Layout.xml Layout.xml added
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.
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
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
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.
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...
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.
Updated by Bert Cuypers about 7 years ago
Okay, thanks for the explanation Roel!