Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
关于特殊控件的事件处理 #60
关于特殊控件的事件处理 #60
Comments
|
在处理特殊形状控件事件中,我采用的方案逆向计算。 主要涉及两个坐标系: 屏幕的物理坐标系 和 画布绘制的坐标系。 正常绘制时坐标系转换:画布坐标系 -> 屏幕物理坐标系 处理触摸事件时坐标系转换屏幕物理坐标系 -> 画布坐标系 所以获取的事件要是屏幕物理坐标系的坐标,才能正常转换为画布坐标系的坐标,也才能正常使用 region 判断。 需要注意的问题注意关闭硬件加速。 |
这个问题是特殊控件的事件处理方案那的,
Region globalRegion = new Region(-w, -h, w, h);
RectF bigCircle = new RectF(-br, -br, br, br);
Region left= new Region();
left.setPath(right_p, globalRegion);
此时 leftRegion 的left 和 top 应该是负数
canvas.translate(mViewWidth / 2, mViewHeight / 2);之后再执行 canvas.getMatrix().invert(mMapMatrix);
mMapMatrix应该就是把坐标系反向偏移回去,就是正常的坐标系,因为left不是正常坐标系的位置,那怎么能用 left.contains(x, y)???
还有就是要是使用event.getY() event.getX() 是不是就可以不用写这句代码了? mMapMatrix.mapPoints(pts);