Given: view A, that holds view B.
Action: I am performing touch and hold on view A with finger 1, and then on view B with finger 2. Then release and the same operation but firstly view B, and then view A. And I expect that views will receive similar events in both cases.
What hapens: when I touch and hold A with finger 1, and then touch and hold B with finger 2, A and B are receiving two separate MotionEvents, each of them holds ACTION_MOVE coords for one pointer:
Logcat:
-----first finger down on view A-------
ACTION_DOWN[#0 (pid 0)=897,392]
----action move for first finger----
ACTION_MOVE[#0 (pid 0)=897,392]
ACTION_MOVE[#0 (pid 0)=897,392]
ACTION_MOVE[#0 (pid 0)=897,392]
ACTION_MOVE[#0 (pid 0)=895,392]
ACTION_MOVE[#0 (pid 0)=896,393]
ACTION_MOVE[#0 (pid 0)=896,394]
ACTION_MOVE[#0 (pid 0)=896,395]
ACTION_MOVE[#0 (pid 0)=896,396]
ACTION_MOVE[#0 (pid 0)=895,396]
ACTION_MOVE[#0 (pid 0)=895,396]
---second finger down on view B-------
ACTION_DOWN[#0 (pid 1)=224,87]
---action move for 1st finger----
ACTION_MOVE[#0 (pid 0)=895,396]
---action move for 2nd finger----
ACTION_MOVE[#0 (pid 1)=224,87]
--first--
ACTION_MOVE[#0 (pid 0)=895,396]
--second--
ACTION_MOVE[#0 (pid 1)=224,87]
etc . . .
ACTION_MOVE[#0 (pid 0)=895,397]
ACTION_MOVE[#0 (pid 1)=224,87]
ACTION_MOVE[#0 (pid 0)=895,397]
ACTION_MOVE[#0 (pid 1)=224,87]
ACTION_MOVE[#0 (pid 0)=895,397]
ACTION_MOVE[#0 (pid 1)=223,87]
ACTION_MOVE[#0 (pid 0)=895,397]
...
BUT, when I firstly touch B, and then A - Android think that it's a multi-touch event and starts to send MotionEvent object that holds ACTION_MOVE coords for 2 pointers to view B only.
Logcat:
----------holding finger at view B------------------
event ACTION_MOVE[#0 (pid 0)=65,33]
event ACTION_MOVE[#0 (pid 0)=62,33]
event ACTION_MOVE[#0 (pid 0)=60,33]
event ACTION_MOVE[#0 (pid 0)=58,33]
event ACTION_MOVE[#0 (pid 0)=56,32]
event ACTION_MOVE[#0 (pid 0)=55,32]
event ACTION_MOVE[#0 (pid 0)=54,32]
event ACTION_MOVE[#0 (pid 0)=54,32]
event ACTION_MOVE[#0 (pid 0)=53,32]
event ACTION_MOVE[#0 (pid 0)=52,32]
event ACTION_MOVE[#0 (pid 0)=52,32]
event ACTION_MOVE[#0 (pid 0)=51,32]
event ACTION_MOVE[#0 (pid 0)=51,33]
----------press on view A with 2nd finger, while holding B with first finger-------------
event ACTION_POINTER_DOWN(pid 1); [#0 (pid 0)=51,33; #1 (pid 1)=1050,-226]
---------action move obj that holds coords for 2 pointers...---------
event ACTION_MOVE[#0 (pid 0)=50,33;#1 (pid 1)=1055,-225]
event ACTION_MOVE[#0 (pid 0)=48,34;#1 (pid 1)=1068,-223]
event ACTION_MOVE[#0 (pid 0)=47,34;#1 (pid 1)=1082,-224]
event ACTION_MOVE[#0 (pid 0)=45,35;#1 (pid 1)=1106,-221]
event ACTION_MOVE[#0 (pid 0)=42,35;#1 (pid 1)=1131,-219]
event ACTION_MOVE[#0 (pid 0)=38,35;#1 (pid 1)=1157,-217]
event ACTION_MOVE[#0 (pid 0)=34,35;#1 (pid 1)=1178,-215]
event ACTION_MOVE[#0 (pid 0)=27,36;#1 (pid 1)=1195,-213]
event ACTION_MOVE[#0 (pid 0)=20,37;#1 (pid 1)=1211,-213]
event ACTION_MOVE[#0 (pid 0)=11,39;#1 (pid 1)=1228,-212]
What I want: I want separate MotionEvents (first case) in both scenarios (first A, then B; and first B, then A)
How I tried to solve it:
-
I tried process only 1 set of coords at view B's
onTouch()
, and then return false, and then consume event at view A, BUT in this scenario I ain't receive anything but ACTION_DOWN at View B. -
I tried to dispatch event in activity in
dispatchTouchEvent()
method and then manually call view A and view BdispatchTouchEvent()
methods, but It hasn't succeed. I tried to pass to ViewGroup (parent layout) and it hasn't succeed too =( onTouch is not called.
But this 2 of my tries I consider as a HACK, I would like to make OS switch back from multi-touch to separate touch events. Do you know how to do that?
from Why android think that I am producing a multi-touch event?
No comments:
Post a Comment