解决lwuit程序在触摸屏中滚动条的方向与定位问题
2010-07-07 10:13
344 查看
在com.sun.lwuit.component的pointerDragged函数,贴出源代码: CODE: /** * If this Component is focused, the pointer dragged event * will call this method * * @param x the pointer x coordinate * @param y the pointer y coordinate */ public void pointerDragged(int x, int y) { if (isScrollable() && isSmoothScrolling()) { int axisValue; if (isScrollableY()) { axisValue = y; } else { axisValue = x; } if (!dragActivated) { dragActivated = true; beforeLastScrollY = axisValue; lastScrollY = axisValue; getComponentForm().setDraggedComponent(this); } //save time and locations to create velocity when the //pointer is released long currentTime = System.currentTimeMillis(); if (currentTime != lastTime[(pLastDragged + lastTime.length + 1) % lastTime.length]) { lastTime[pLastDragged] = System.currentTimeMillis(); lastDragged[pLastDragged] = axisValue; pLastDragged = (++pLastDragged) % lastTime.length; } beforeLastScrollY = lastScrollY; lastScrollY = axisValue; // we drag inversly to get a feel of grabbing a physical screen // and pulling it in the reverse direction of the drag if (isScrollableY()) { //解决滚动条定位问题和方向问题-----begin int h = getHeight() - getStyle().getPadding(TOP) - getStyle().getPadding(BOTTOM); int scroll = getScrollY() - (beforeLastScrollY - axisValue)*getPreferredH()/h; //解决滚动条定位问题和方向问题-----end if (scroll >= 0 && scroll < getPreferredH() - getHeight()) { setScrollY(scroll); } } else { int scroll = getScrollX() - (beforeLastScrollY - axisValue); if (scroll >= 0 && scroll < getPreferredW() - getWidth()) { setScrollX(scroll); } } } else { //try to find a scrollable element until you reach the Form Component parent = getParent(); if (!(parent instanceof Form)) { parent.pointerDragged(x, y); } } }
相关文章推荐
- pe模式安装win7(32位)的时候出现“安装程序无法定位现有系统分区,也无法创建新的系统分区”提示,网上很多对此问题没有很好的解决办法
- pl/sql 无法定位程序输入点 于动态链接库 ...于oraociei12.dll 问题的解决办法
- 解决相对定位随滚动条滚动可以无限下滑的问题
- 解决 WinXP下 libcurl.dll 无法定位程序输入点GetTickCount64问题
- 解决微信公众号、小程序切换 webview 后无法定位元素的问题
- 程序触摸屏解决QT程序触摸屏不可用的问题
- "安装程序无法定位现有系统分区" 问题解决
- 无法定位程序输入点XXXXX于动态链接库qtcore.dll(自已遇到同样问题,转载解决问题方法)
- 解决 p0sixspwn-v1.0.4 win版 无法定位程序输入点sqlite3_wal_checkpoint的问题
- Qt中关于无法定位程序输入点的一种问题解决方式
- 解决“无法定位程序输入点ucrtbase.terminate于动态链接库api-ms-win-crt-runtime-|1-1-0.dll“问题
- Release模式下加载FFmpeg提示“无法定位程序输入点XXX与动态链接库XXX.dll ”的问题解决
- Ext的Window在IE6中滚动条失效,定位,布局问题等解决办法
- 完美解决XP无法定位程序输入点RegGetValue于动态链接库ADVAPI32.dll,XP,win7注册表读取问题
- 安装itunes出现无法定位程序输入点(QTCF)的问题解决方法
- 【问题解决】无法定位程序输入点~于动态链接库上(The procedure entry point ~ could not be located)
- [已解决]Delphi XE10 Android 程序引用百度定位Jar包后, 某些手机上闪退的问题
- 解决“安装程序无法创建新的系统分区,也无法定位现有系统分区”问题方法
- 解决单文档滚动条程序中显示图像闪烁问题
- 升级成iOS8后程序不能定位的问题解决