Bug #6105
Added by Bert Cuypers almost 5 years ago.
Updated over 4 years ago.
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
Could you maybe provide some example code demonstrating the issue? I can't seem to reproduce it with the latest master.
- Status changed from New to Feedback
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.
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
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
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.
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...
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.
Okay, thanks for the explanation Roel!
Also available in: Atom
PDF