Project

General

Profile

How to programmatically set focus to WPaintedWidget

Added by Cameron Angus almost 10 years ago

I have a WPaintedWidget-derived widget, on which I've called setAttributeValue("tabindex", "0") in order to allow the widget to receive focus.

This works as expected in response to user input, however I now want to set the focus to the widget from within a button click event handler. setFirstFocus() seems to have no effect, perhaps because the widget is not derived from WFormWidget, or has no children?

Is there a simple way to achieve this, without having to do some kind of low level input insertion workaround?

Thanks,

Cameron.


Replies (2)

RE: How to programmatically set focus to WPaintedWidget - Added by Koen Deforche almost 10 years ago

Hey,

setFirstFocus() will indeed only consider form widgets. We should thus also consider those that you manually configure to get focus.

Can you file a bug for this?

Regards,

koen

RE: How to programmatically set focus to WPaintedWidget - Added by Cameron Angus almost 10 years ago

Sure, done.

Is there some reason why there is a not a setFocus() method somewhere higher up the widget class hierarchy than WFormWidget? It seems that there are a number of existing core Wt widgets (WMenu?) which are not derived from WFormWidget, yet require focus capability.

Cameron.

    (1-2/2)