RFC: Fl::focus(Fl_Widget*) should be independent of Fl_Widget::visible_focus()

9 views
Skip to first unread message

Albrecht Schlosser

unread,
Jan 11, 2022, 8:03:17 AM1/11/22
to fltk.coredev
All,

I filed issue #366 "Fl::focus(Fl_Widget*) should be independent of Fl_Widget::visible_focus()"
https://github.com/fltk/fltk/issues/366

Abstract:

"Setting the focus to a widget that has disabled keyboard navigation by calling Fl_Widget::clear_visible_focus() or Fl_Widget::visible_focus(0) fails because Fl::focus(Fl_Widget*) tests the Fl_Widget::visible_focus() attribute. This should not be done since Fl::focus(Fl_Widget*) should set the focus to the widget unconditionally."

For further information and links to documentation and code please see the GitHub issue (link above).

I suggest to remove the offending statement
(https://github.com/fltk/fltk/blob/42a93eb8dec6e3c637442e23e156b3f72c7f8ca7/src/Fl.cxx#L829)

if (o && !o->visible_focus()) return;

but I wanted to ask for comments and opinions first.

This check exists since the new VISIBLE_FOCUS flag had been introduced in 2002 but I believe that this is a bug.
https://github.com/fltk/fltk/blob/57cef6a4bde017e205e54271e769de0db596d893/src/Fl.cxx#L422

A related issue is
issue #365 "Make class Fl_Simple_Terminal refuse the focus"
https://github.com/fltk/fltk/issues/365

Comments, anybody?

Please use this thread for discussion or add a comment to the GitHub issue. Thanks.

Bill Spitzak

unread,
Jan 11, 2022, 6:01:20 PM1/11/22
to fltkc...@googlegroups.com
Make sure nothing calling it is relying on that test failing (for instance maybe that is how navigation skips the widgets). I agree it should be unconditional and any such tests moved to the calling code.


--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/108e79aa-46aa-f98c-eebd-da9d13e3774c%40online.de.

Albrecht Schlosser

unread,
Jan 11, 2022, 6:35:48 PM1/11/22
to fltkc...@googlegroups.com
On 1/12/22 12:01 AM Bill Spitzak wrote:
Make sure nothing calling it is relying on that test failing (for instance maybe that is how navigation skips the widgets).

I'm in a process of checking this. However we can never know if user code was calling the wrong function. TAB navigation must find a widget that accepts the focus, i.e. it must already use take_focus() or check it before it calls Fl::focus() and thus we're safe here because otherwise it would not work at all.


I agree it should be unconditional and any such tests moved to the calling code.

Thanks for your comment, I appreciate this very much.


Bill Spitzak

unread,
Jan 11, 2022, 7:17:00 PM1/11/22
to fltkc...@googlegroups.com
I would not worry about user code

Reply all
Reply to author
Forward
0 new messages