Previously, RotaryEvents could always be received only by window.
Now, User can receive Rotary Events in focused View as well.
It is also possible to propagate events to the parent view.
If there is no focused View, the window will receive the event.
This only applies to Rotary Event(CustomWheel type).
Change-Id: Ifc2f180246bb282efeb5094f970f38b0b76d8dad
Dali::Integration::SceneHolder::WheelEventSignalType& WheelEventSignal();
+ Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
+
Integration::Scene GetScene();
Dali::RenderSurfaceInterface& GetRenderSurface();
return mScene.WheelEventSignal();
}
+Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
+{
+ return mScene.WheelEventGeneratedSignal();
+}
+
Integration::Scene SceneHolder::GetScene()
{
return mScene;
return GetImplementation( *this ).WheelEventSignal();
}
+SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
+{
+ return GetImplementation( *this ).WheelEventGeneratedSignal();
+}
+
} // Integration
} // Dali
return GetImplementation( window ).WheelEventSignal();
}
+WheelEventGeneratedSignalType& WheelEventGeneratedSignal( Window window )
+{
+ return GetImplementation( window ).WheelEventGeneratedSignal();
+}
+
VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
{
return GetImplementation( window ).mVisibilityChangedSignal;
typedef Signal< void () > EventProcessingFinishedSignalType;
typedef Signal< bool (const KeyEvent&) > KeyEventGeneratedSignalType;
typedef Signal< void (const WheelEvent&) > WheelEventSignalType;
+typedef Signal< bool (const WheelEvent&) > WheelEventGeneratedSignalType;
typedef Signal< void ( Window, bool ) > VisibilityChangedSignalType;
Dali::Window Get( Actor actor );
EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window );
KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Dali::Window window );
WheelEventSignalType& WheelEventSignal( Window window );
+WheelEventGeneratedSignalType& WheelEventGeneratedSignal( Dali::Window window );
VisibilityChangedSignalType& VisibilityChangedSignal( Window window );
}
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/focus-manager/keyboard-focus-manager-devel.h>
bool mIsCalled;
};
+class WheelEventCallback : public Dali::ConnectionTracker
+{
+public:
+ /**
+ * Constructor
+ * @param[in] returnValue Set return value of WheelEvent callback.
+ * */
+ WheelEventCallback( bool consumed )
+ : mConsumed( consumed ),
+ mIsCalled( false )
+ {
+ }
+
+ bool Callback( Actor actor, const WheelEvent& wheelEvent )
+ {
+ mIsCalled = true;
+ return mConsumed;
+ }
+
+ void Callback( const WheelEvent& wheelEvent )
+ {
+ mIsCalled = true;
+ }
+
+ bool mConsumed;
+ bool mIsCalled;
+};
+
// Used to connect to signals via the ConnectSignal Handle method
struct CallbackFunctor
{
DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
END_TEST;
+}
+
+int UtcDaliKeyboardFocusManagerCheckWheelEvent(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliKeyboardFocusManagerCheckWheelEvent" );
+ Dali::Integration::Scene scene = application.GetScene();
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
+
+ // Create the first actor and add it to the stage
+ Actor parent = Actor::New();
+ parent.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
+
+ Actor child = Actor::New();
+ child.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
+
+ parent.Add(child);
+ scene.Add(parent);
+
+ WheelEventCallback childCallback( false );
+ child.WheelEventSignal().Connect( &childCallback, &WheelEventCallback::Callback );
+
+ WheelEventCallback parentCallback( true );
+ parent.WheelEventSignal().Connect( &parentCallback, &WheelEventCallback::Callback );
+
+ WheelEventCallback sceneCallback( false );
+ scene.WheelEventSignal().Connect( &sceneCallback, &WheelEventCallback::Callback );
+
+ manager.SetCurrentFocusActor( child );
+
+ // Emit custom wheel event is comming to KeyboardFocusManager
+ Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
+ application.ProcessEvent(event);
+
+ DALI_TEST_CHECK( childCallback.mIsCalled );
+ DALI_TEST_CHECK( parentCallback.mIsCalled );
+ DALI_TEST_CHECK( !sceneCallback.mIsCalled );
+
+ END_TEST;
}
\ No newline at end of file
{
(*iter).KeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
(*iter).TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch);
+ (*iter).WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent);
Dali::Window window = DevelWindow::DownCast(*iter);
if(window)
{
{
sceneHolder.KeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
sceneHolder.TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch);
+ sceneHolder.WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent);
Dali::Window window = DevelWindow::DownCast(sceneHolder);
if(window)
{
}
}
+bool KeyboardFocusManager::OnWheelEvent(const WheelEvent& event)
+{
+ bool consumed = false;
+ Actor actor = GetCurrentFocusActor();
+ if(actor)
+ {
+ // Notify the actor about the wheel event
+ consumed = EmitWheelSignals(actor, event);
+ }
+ return consumed;
+}
+
+bool KeyboardFocusManager::EmitWheelSignals(Actor actor, const WheelEvent& event)
+{
+ bool consumed = false;
+
+ if(actor)
+ {
+ Dali::Actor oldParent(actor.GetParent());
+
+ // Only do the conversion and emit the signal if the actor's wheel signal has connections.
+ if(!actor.WheelEventSignal().Empty())
+ {
+ // Emit the signal to the parent
+ consumed = actor.WheelEventSignal().Emit(actor, event);
+ }
+ // if actor doesn't consume WheelEvent, give WheelEvent to its parent.
+ if(!consumed)
+ {
+ // The actor may have been removed/reparented during the signal callbacks.
+ Dali::Actor parent = actor.GetParent();
+
+ if(parent &&
+ (parent == oldParent))
+ {
+ consumed = EmitWheelSignals(parent, event);
+ }
+ }
+ }
+
+ return consumed;
+}
+
void KeyboardFocusManager::OnWindowFocusChanged(Window window, bool focusIn)
{
if(focusIn && mCurrentFocusedWindow.GetHandle() != window.GetRootLayer())
void OnTouch(const TouchEvent& touch);
/**
+ * Callback for the wheel event when the custom wheel event occurs.
+ * @param[in] wheel The WheelEvent information
+ */
+ bool OnWheelEvent(const WheelEvent& wheel);
+
+ /**
* Called when the window focus is changed.
* @param[in] window The window whose focus is changed
* @param[in] focusIn Whether the focus is in/out
*/
Actor GetFocusActorFromCurrentWindow();
+ /**
+ * Recursively deliver events to the control and its parents, until the event is consumed or the stage is reached.
+ * @param[in] actor The actor got WheelEvent.
+ * @param[in] event The WheelEvent.
+ * @return True if WheelEvent is consumed.
+ */
+ bool EmitWheelSignals(Actor actor, const WheelEvent& event);
+
private:
// Undefined
KeyboardFocusManager(const KeyboardFocusManager&);