[GTK] ListView gets keyboard focus when SetFocus is called. #310

Closed
wants to merge 1 commit into from

3 participants

@mrward
Mono Project member

Calling ListView.SetFocus() was not getting the keyboard focus so the up/down arrow keys did not select the next list view item.

@slluis
Mono Project member

Can't this be handled at the WidgetBackend class?

@mrward
Mono Project member

You mean move the code up to the WidgetBackend class into its SetFocus() method?

There is code to do the widget.GrabFocus() already in the WidgetBackend.SetFocus() method but it is commented out for some reason. I assumed, probably incorrectly, that the WidgetBackend code was deliberately not calling GrabFocus for some reason.

https://github.com/mono/xwt/blob/listview-focus/Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs#L167

@sevoku
Mono Project member

According to the GTK Api (https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-is-focus) IsFocus is only to determine the focus state, so to really set the focus, GrabFocus should be called, if the Widget.CanFocus is true (and only then). So I think SetFocus can be uncommented in https://github.com/mono/xwt/blob/listview-focus/Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs#L167 and a check for CanGetFocus should be added to SetFocus in https://github.com/mono/xwt/blob/listview-focus/Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs#L174

@sevoku sevoku referenced this pull request Jan 22, 2015
Merged

[Gtk] fix SetFocus #473

@sevoku
Mono Project member

I've added #473 that always calls GrabFocus. I think it should work for all widgets.

@sevoku sevoku added this to the v0.2 milestone Jan 30, 2015
@sevoku
Mono Project member

I've merged #473 (passes focus tests), so this can be closed.

@sevoku sevoku closed this Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment