Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu Drawer will grab focus when Not currently Shown #207

Open
kingargyle opened this issue Jan 2, 2014 · 4 comments
Open

Menu Drawer will grab focus when Not currently Shown #207

kingargyle opened this issue Jan 2, 2014 · 4 comments

Comments

@kingargyle
Copy link

Currently I'm using Menu Drawer with the serenity-for-android project. One thing I've noticed is that items in the menu drawer will gain focus periodically when using a D-Pad for navigation and the menu drawer is currently not displayed.

In order to work around this, I've had to make sure items in the drawer are not visibile views when the drawer is off screen. However this makes for some messy coding when trying to get the drawer working the same between a Touch screen interface and one where only a D-Pad is available. It would be nice to have the Menu Drawer only respond to Focus events if the Drawer and it's items are visible on the screen, otherwise none of the drawer items should respond to request for focus.

@way2jatin
Copy link

Hi @kingargyle ,

Can you please explain the above via a code sample ? Even i m also facing the same issue and having problems resolving them .

@kingargyle
Copy link
Author

Basicly when you close the drawer you need to make all the views in the drawer invisible. Then when the drawer opens, make the views visible and set the focus to one of the newly visible views.

@way2jatin
Copy link

I tried with the following code sample ...

mMenuDrawer.getMenuDrawer().setOnDrawerStateChangeListener(new OnDrawerStateChangeListener() {
            @Override
            public void onDrawerStateChange(final int oldState, final int newState) {
                if (newState == MenuDrawer.STATE_CLOSED){
                    mMenuDrawer.getMenuView().setVisibility(View.GONE);
                }
                else {
                    mMenuDrawer.getMenuView().setVisibility(View.VISIBLE);
                }
            }
        });

But i m still facing the same issue. Although , if i enable hardwareAccelerated as true for the activity, then it works fine.

@kingargyle
Copy link
Author

I also specifically call requestFocus when opening and closing the drawers to help give the system some info on which item should have focus when opening and closing the drawers.

https://github.com/NineWorlds/serenity-android/blob/develop/serenity-app/src/main/java/us/nineworlds/serenity/MainActivity.java#L151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants