Results 1 to 3 of 3

Thread: Moving focus around

  1. #1
    Join Date
    Jun 2007

    Default Moving focus around

    I've been looking at getting tab focus working and run into a bit of trouble with radio buttons. Thing is, when tabbing around, the selected radiobutton in a radio group should receive the focus. CL_GUIComponent would thus need to know which radio button is selected to be able to give the right component focus.

    To achieve this without CL_GUIComponent actually knowing about the component, I was thinking we could move the group functionality from radiobutton to CL_GUIComponent. CL_GUIComponent would also have to be able to find out which component in a group is selected. So something like:

    class CL_GUIComponent
        void set_component_group_name(const CL_String &group_name);
        void set_selected_in_group(bool selected);
    Also the FocusPolicy enum would get a new entry: focus_group.
    I couldn't think of what focus_parent would be used for? If a component doesn't process some event and take focus, that event will go to the parent which should then set itself focused, if it so desires.

    I have added the following to the GUI specification:

    • If FocusPolicy of the currently focused component is focus_group, all components with the same group-name -attribute will be skipped over.
    • If FocusPolicy of the component to be focused is focus_group, the focus is set on the selected component in the group. If no component in the group is set as selected, normal focus changing rules apply.
    • Focus graphics (dashed line surrounding text) is drawn on the focused component only after the keyboard has been used to navigate the dialog. Otherwise focus indication is not drawn.
    • Focusable components receive focus on mouse clicks after keyboard navigation has been used in a dialog.

    Alternatively we could just let radiobuttons deal with their focus problems internally, but I'm not really sure which approach would be better. I'm in favor of letting CL_GUIComponent do the focus changes so that components don't have to worry about it.

    Any thoughts?

    (The focus changing code I committed is still work in progress, with some bugs at least when going backwards.)

  2. #2
    ClanLib Developer
    Join Date
    May 2007


    Quote Originally Posted by Harry View Post
    (The focus changing code I committed is still work in progress, with some bugs at least when going backwards.)
    I can't seem to get it to work at all here.

    In the GUI example:
    1) notice the "Aero" radio tab is selected.
    2) Click on "Luna" radio tab
    3) On the keyboard, press cursor down - Nothing happens
    4) On the keyboard, press cursor up...

    The program goes into an infinite loop inside CL_GUIComponent::focus_next()

  3. #3
    Join Date
    Jun 2007


    I have implemented the radio button focusing as described in the first message.

    Focus moving by tab/shift-tab should mostly be working now. I have added focus graphics to CL_RadioButton, CL_TabHeader and CL_Slider. I also improved their keyboard support. A few issues remain:

    - CL_ComboBox opens the dropdown menu when it gets focus and the openend window gets all tab key presses so there is no tabbing out of the menu. The menu shouldn't be opened before pressing down in the lineedit or pressing space/enter when the button is focused.

    - Something happens in the GUI example in the Spin window when moving around using the arrow keys - focus starts jumping between just two items. Using the tab key works though. (Seems to be related to the lineedits, but i haven't investigated any deeper.)

Similar Threads

  1. Help Need, moving Dink
    By Arjayty in forum RTsoft Tavern
    Replies: 0
    Last Post: 11-05-2008, 11:35 AM
  2. No focus for button under mouse when gui changes
    By LonelyStar in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 05-05-2008, 01:49 PM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts