X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ffocus-manager%2Fkeyboard-focus-manager-impl.cpp;h=21a03493c222c13875f227c6fd03e8a84bb05eab;hp=a9822e7dc2ddcc3e8b4da590b1b71bf4a4ce7afd;hb=9dc9e248aa53b097c6a41fb043c3d5341f93ec45;hpb=80ab4492a0df45c146d9ad97daef3c522bb02e2c diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index a9822e7..21a0349 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace Dali { @@ -117,17 +118,14 @@ KeyboardFocusManager::KeyboardFocusManager() mCurrentFocusActor( 0 ), mFocusIndicatorActor(), mFocusGroupLoopEnabled( false ), - mIsKeyboardFocusEnabled( false ), mIsFocusIndicatorEnabled( false ), mIsWaitingKeyboardFocusChangeCommit( false ), mFocusHistory(), mSlotDelegate( this ) { - OnPhysicalKeyboardStatusChanged(PhysicalKeyboard::Get()); - + // TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorEnabled. Toolkit::KeyInputFocusManager::Get().UnhandledKeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent); Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch ); - PhysicalKeyboard::Get().StatusChangedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnPhysicalKeyboardStatusChanged); } KeyboardFocusManager::~KeyboardFocusManager() @@ -155,16 +153,24 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID ) // Check whether the actor is in the stage and is keyboard focusable. if( actor && actor.IsKeyboardFocusable() ) { - mIsFocusIndicatorEnabled = true; - // Draw the focus indicator upon the focused actor when PhysicalKeyboard is attached - if( mIsKeyboardFocusEnabled ) + if( mIsFocusIndicatorEnabled ) { actor.Add( GetFocusIndicatorActor() ); } // Send notification for the change of focus actor + Actor currentFocusedActor = GetCurrentFocusActor(); + if( !mFocusChangedSignal.Empty() ) { - mFocusChangedSignal.Emit(GetCurrentFocusActor(), actor); + mFocusChangedSignal.Emit(currentFocusedActor, actor); + } + + Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast(currentFocusedActor); + if( currentlyFocusedControl ) + { + // Do we need it to remember if it was previously DISABLED? + currentlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::NORMAL ); + currentlyFocusedControl.ClearKeyInputFocus(); } DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__); @@ -172,6 +178,13 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID ) // Save the current focused actor mCurrentFocusActor = actorID; + Toolkit::Control newlyFocusedControl = Toolkit::Control::DownCast(actor); + if( newlyFocusedControl ) + { + newlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::FOCUSED ); + newlyFocusedControl.SetKeyInputFocus(); + } + // Push Current Focused Actor to FocusHistory mFocusHistory.PushBack( &actor.GetBaseObject() ); @@ -404,17 +417,24 @@ void KeyboardFocusManager::DoKeyboardEnter(Actor actor) void KeyboardFocusManager::ClearFocus() { Actor actor = GetCurrentFocusActor(); - if(actor) + if( actor ) { - if(mFocusIndicatorActor) + if( mFocusIndicatorActor ) { - actor.Remove(mFocusIndicatorActor); + actor.Remove( mFocusIndicatorActor ); } // Send notification for the change of focus actor if( !mFocusChangedSignal.Empty() ) { - mFocusChangedSignal.Emit(actor, Actor()); + mFocusChangedSignal.Emit( actor, Actor() ); + } + + Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast( actor ); + if( currentlyFocusedControl ) + { + currentlyFocusedControl.SetProperty( DevelControl::Property::STATE, DevelControl::NORMAL ); + currentlyFocusedControl.ClearKeyInputFocus(); } } @@ -507,39 +527,8 @@ Actor KeyboardFocusManager::GetFocusIndicatorActor() return mFocusIndicatorActor; } -void KeyboardFocusManager::OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard) -{ - mIsKeyboardFocusEnabled = keyboard.IsAttached(); - - if(mIsKeyboardFocusEnabled) - { - // Show indicator when keyboard focus turned on if there is focused actor. - Actor actor = GetCurrentFocusActor(); - if(actor) - { - actor.Add( GetFocusIndicatorActor() ); - } - mIsFocusIndicatorEnabled = true; - } - else - { - // Hide indicator when keyboard focus turned off - Actor actor = GetCurrentFocusActor(); - if( actor && mFocusIndicatorActor ) - { - actor.Remove( mFocusIndicatorActor ); - } - mIsFocusIndicatorEnabled = false; - } -} - void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { - if(!mIsKeyboardFocusEnabled) - { - return; - } - AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get(); bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled(); @@ -627,6 +616,36 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } + else if (keyName == "Prior" && !isAccessibilityEnabled) + { + if(!mIsFocusIndicatorEnabled) + { + // Show focus indicator + mIsFocusIndicatorEnabled = true; + } + else + { + // Move the focus towards the previous page + MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_UP); + } + + isFocusStartableKey = true; + } + else if (keyName == "Next" && !isAccessibilityEnabled) + { + if(!mIsFocusIndicatorEnabled) + { + // Show focus indicator + mIsFocusIndicatorEnabled = true; + } + else + { + // Move the focus towards the next page + MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_DOWN); + } + + isFocusStartableKey = true; + } else if (keyName == "Tab" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled)