window.Reset();
END_TEST;
}
+
+int UtcDaliKeyInputFocusManagerKeyEventOtherWindow(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliKeyInputFocusManagerSignalKeyEventOtherWindow");
+
+ Dali::Integration::Scene scene = application.GetScene();
+
+ KeyInputFocusManager manager = KeyInputFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ PushButton pushButton1 = PushButton::New();
+ scene.Add(pushButton1);
+
+ KeyEventCallback windowCallback(false);
+ pushButton1.KeyEventSignal().Connect(&windowCallback, &KeyEventCallback::Callback);
+
+ manager.SetFocus(pushButton1);
+
+ Integration::KeyEvent event("a", "", "a", 0, 0, 0, Integration::KeyEvent::UP, "", "", Device::Class::TOUCH, Device::Subclass::NONE);
+ event.windowId = 3;
+
+ application.ProcessEvent(event);
+
+ DALI_TEST_CHECK(!windowCallback.mIsCalled);
+
+ END_TEST;
+}
END_TEST;
}
+
+int UtcDaliKeyboardFocusManagerKeyEventOtherWindow(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliKeyboardFocusManagerKeyEventOtherWindow");
+
+ Dali::Integration::Scene scene = application.GetScene();
+
+ // Register Type
+ TypeInfo type;
+ type = TypeRegistry::Get().GetTypeInfo("KeyboardFocusManager");
+ DALI_TEST_CHECK(type);
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK(handle);
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+
+ PushButton button1 = PushButton::New();
+ PushButton button2 = PushButton::New();
+ button1.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ button2.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ application.GetScene().Add(button1);
+ application.GetScene().Add(button2);
+
+ // Set the focus to the button1
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(button1) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
+
+ // set the navigation properties of button1
+ button1.SetProperty(Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty<int>(Actor::Property::ID)));
+ button1.SetProperty(Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty<int>(Actor::Property::ID)));
+ button1.SetProperty(Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty<int>(Actor::Property::ID)));
+ button1.SetProperty(Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty<int>(Actor::Property::ID)));
+ button1.SetProperty(Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID)));
+ button1.SetProperty(Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID)));
+
+ Integration::KeyEvent event("Right", "", "Right", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
+ // It makes mIsFocusIndicatorEnabled true
+ application.ProcessEvent(event);
+
+ // Move the focus towards right
+ application.ProcessEvent(event);
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button2);
+
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(button1) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
+
+ Integration::KeyEvent event1("Right", "", "Right", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE);
+ event1.windowId = 3;
+ application.ProcessEvent(event1);
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
+
+ END_TEST;
+}
\ No newline at end of file
mFocusGroupLoopEnabled(false),
mIsWaitingKeyboardFocusChangeCommit(false),
mClearFocusOnTouch(true),
- mEnableDefaultAlgorithm(false)
+ mEnableDefaultAlgorithm(false),
+ mCurrentWindowId(0)
{
// TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorShown.
{
Layer rootLayer = currentWindow.GetRootLayer();
mCurrentFocusedWindow = rootLayer;
+ mCurrentWindowId = static_cast<uint32_t>(currentWindow.GetNativeId());
}
if((mIsFocusIndicatorShown == SHOW) && (mEnableFocusIndicator == ENABLE))
return mFocusIndicatorActor;
}
+uint32_t KeyboardFocusManager::GetCurrentWindowId() const
+{
+ return mCurrentWindowId;
+}
+
void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
{
+ if(mCurrentFocusedWindow.GetHandle())
+ {
+ // If it is a key event that occurred in another window, it returns.
+ uint32_t eventWindowId = event.GetWindowId();
+ if(eventWindowId > 0 && GetCurrentWindowId() != eventWindowId)
+ {
+ DALI_LOG_RELEASE_INFO("CurrentFocusedWindow id %d, window ID where key event occurred %d : key event skip\n", GetCurrentWindowId(), eventWindowId);
+ return;
+ }
+ }
+
const std::string& keyName = event.GetKeyName();
const std::string& deviceName = event.GetDeviceName();
// Change Current Focused Window
Layer rootLayer = window.GetRootLayer();
mCurrentFocusedWindow = rootLayer;
+ mCurrentWindowId = static_cast<uint32_t>(Integration::SceneHolder::Get(rootLayer).GetNativeId());
// Get Current Focused Actor from window
Actor currentFocusedActor = GetFocusActorFromCurrentWindow();
*/
void ClearFocusIndicator();
+ /**
+ * Gets the current native window id
+ */
+ uint32_t GetCurrentWindowId() const;
+
private:
// Undefined
KeyboardFocusManager(const KeyboardFocusManager&);
bool mEnableDefaultAlgorithm : 1; ///< Whether use default algorithm focus
+ uint32_t mCurrentWindowId; ///< The current native window id
+
};
} // namespace Internal
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/scene-holder.h>
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/public-api/actors/layer.h>
#include <cstring> // for strcmp
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-devel.h>
-
namespace Dali
{
namespace Toolkit
KeyInputFocusManager::KeyInputFocusManager()
: mSlotDelegate(this),
- mCurrentFocusControl()
+ mCurrentFocusControl(),
+ mCurrentWindowId(0)
{
// Retrieve all the existing widnows
Dali::SceneHolderList sceneHolders = Adaptor::Get().GetSceneHolders();
// Set control to currentFocusControl
mCurrentFocusControl = control;
+ mCurrentWindowId = static_cast<uint32_t>(Integration::SceneHolder::Get(control).GetNativeId());
if(previousFocusControl)
{
control.OffSceneSignal().Disconnect(mSlotDelegate, &KeyInputFocusManager::OnFocusControlSceneDisconnection);
mCurrentFocusControl.Reset();
+ mCurrentWindowId = 0;
// Notify the control that it has lost key input focus
GetImplementation(control).OnKeyInputFocusLost();
return mCurrentFocusControl;
}
+uint32_t KeyInputFocusManager::GetCurrentWindowId() const
+{
+ return mCurrentWindowId;
+}
+
Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusManager::KeyInputFocusChangedSignal()
{
return mKeyInputFocusChangedSignal;
Toolkit::Control control = GetCurrentFocusControl();
if(control)
{
+ // Key events that occur in windows other than the currently focused control are skipped.
+ uint32_t eventWindowId = event.GetWindowId();
+ if(eventWindowId > 0 && GetCurrentWindowId() != eventWindowId)
+ {
+ DALI_LOG_RELEASE_INFO("Current control window id %d, window ID where key event occurred %d : key event skip\n", GetCurrentWindowId(), eventWindowId);
+ return consumed;
+ }
+
Dali::Actor dispatch = control;
while(dispatch)
{
*/
bool EmitKeyEventSignal(Toolkit::Control control, const KeyEvent& event);
+ /**
+ * Gets the current native window id
+ */
+ uint32_t GetCurrentWindowId() const;
+
private:
// Undefined
KeyInputFocusManager(const KeyInputFocusManager&);
SlotDelegate<KeyInputFocusManager> mSlotDelegate;
Toolkit::Control mCurrentFocusControl; ///< The current focused control
+ uint32_t mCurrentWindowId; ///< The native window id of current focused control
};
} // namespace Internal