Android浏览器触摸事件位置(Android browser touch event location)
在Safari上,您可以从event.pageX和event.pageY获取用户触摸屏幕的位置。 但是,在我的Android浏览器上,event.pageX和event.pageY始终为0.有没有办法在Android上的浏览器中获取触摸事件的位置?
On Safari, you can get the location of where the user touched the screen from event.pageX and event.pageY. However, on my Android browser, event.pageX and event.pageY are always 0. Is there any way to get the location of a touch event in the browser on Android?
原文:https://stackoverflow.com/questions/8371781
最满意答案
有些东西马上跳出来,你正在测试参数是否等于
-q
byif( strcmp( argv[1], "-q" ) != 0) //This is an example of what I am trying to do. { quiet = true; infile.open( argv[2] ); }
哪个不对。 strcmp返回两个字符串之间的词法差异: http : //www.cplusplus.com/reference/cstring/strcmp/
所以我相信你想要的
if( strcmp( argv[1], "-q" ) == 0) //This is an example of what I am trying to do. { quiet = true; infile.open( argv[2] ); }
就像我说的,我没有测试任何东西,它只是跳出来对我说。
编辑
我将如何解析sourcefile,destfile和-q选项
std::string sourceFile; std::string destFile; if ( argc == 3 ) { sourceFile = std::string( argv[1] ); destFile = std::string( argv[2] ); } else if ( argc == 4 ) { // quiet mode is enabled std::string arg1( argv[1] ); std::string arg2( argv[2] ); std::string arg3( argv[3] ); if ( arg1 != "-q" ) vec.push_back( std::string( arg1 ); if ( arg2 != "-q" ) vec.push_back( std::string( arg2 ); if ( arg3 != "-q" ) vec.push_back( std::string( arg3 ); if ( vec.size() != 2 ) { // maybe error? } else { sourceFile = vec[0]; destFile = vec[1]; } }
当然不是那么干净,我没有测试过,所以可能会有一个小错误。
Something jumped out at me right away, you're testing if the argument equals
-q
byif( strcmp( argv[1], "-q" ) != 0) //This is an example of what I am trying to do. { quiet = true; infile.open( argv[2] ); }
which is incorrect. strcmp returns the lexical difference between the two strings compared : http://www.cplusplus.com/reference/cstring/strcmp/
so I believe you want
if( strcmp( argv[1], "-q" ) == 0) //This is an example of what I am trying to do. { quiet = true; infile.open( argv[2] ); }
Like I said, I haven't tested anything, it just jumped out at me.
edit
how I would parse in the sourcefile, destfile, and -q option
std::string sourceFile; std::string destFile; if ( argc == 3 ) { sourceFile = std::string( argv[1] ); destFile = std::string( argv[2] ); } else if ( argc == 4 ) { // quiet mode is enabled std::string arg1( argv[1] ); std::string arg2( argv[2] ); std::string arg3( argv[3] ); if ( arg1 != "-q" ) vec.push_back( std::string( arg1 ); if ( arg2 != "-q" ) vec.push_back( std::string( arg2 ); if ( arg3 != "-q" ) vec.push_back( std::string( arg3 ); if ( vec.size() != 2 ) { // maybe error? } else { sourceFile = vec[0]; destFile = vec[1]; } }
Certainly not as clean as possible, and I haven't tested it so there may be a small error.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
该文章依赖于Q()接受args和kwargs的未记录的特性。 如果查看Q类的源代码 ,可以看到它在__init__方法中执行以下操作。 class Q(tree.Node): ... def __init__(self, *args, **kwargs): super(Q, self).__init__(children=list(args) + list(kwargs.items())) 如果你打电话给Q(question__contains=dinner)那么args在 ...
-
有些东西马上跳出来,你正在测试参数是否等于-q by if( strcmp( argv[1], "-q" ) != 0) //This is an example of what I am trying to do. { quiet = true; infile.open( argv[2] ); } 哪个不对。 strcmp返回两个字符串之间的词法差异: http : //www.cplusplus.com/reference/cstring/strcmp/ 所以我相信你想要的 if( s ...
-
如何在KDB / Q中获取可用功能及其参数列表?(How to get list of available functions and their parameters in KDB/Q?)[2022-02-10]
http://code.kx.com/q/ref/syscmds/#f-functions \f . \f .namspace 对于函数,您只需通过给出函数名称来单独检查参数 .n.function 不仅会给你参数,还会给你整个函数的定义。 http://code.kx.com/q/ref/syscmds/#f-functions \f . \f .namspace For functions you will have to check parameters individually by just ... -
如何使用另一个文件中的参数列表运行Makefile(How to run a Makefile with a list of arguments from another file)[2022-03-21]
这对我有效: 配置文件(不需要反斜杠): --alpha 3 --beta 5 --gamma 5 MYPROG: #!/bin/bash echo "arg1=$1" echo "arg2=$2" Makefile文件: # define the newline as a multi-line variable define \n endef # Convert newlines to spaces in $(ARGS) MK_ARGS := $(subst ${\n}, , $(ARGS)) ... -
在C++如果你把默认参数放在最后的位置。 另外,QObject参数应该传递给基类构造函数。 例如: class renderJob: public {BaseObjectClass} { Q_OBJECT public: explicit renderJob(QString userInput, QObject *parent = 0); } [...] renderJob::renderJob(QString userInput, QObject *parent): {BaseObje ...
-
在KDB + / q中构建列表(Building a list in KDB+ / q)[2022-03-10]
使用每个来实现这一目标 q) til each 2 3 0 1 0 1 2 Use each to achieve this q) til each 2 3 0 1 0 1 2 -
这可以通过使用Wagtail的ModelAdmin模块( http://docs.wagtail.io/en/v1.8.1/reference/contrib/modeladmin/ )轻松解决,您只需要将这段代码添加到wagtail_hooks.py中文件: from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register) from .models import Product class Pro ...
-
像这样的东西你想要什么? sage: q=1 sage: n=3 sage: L = IntegerListsLex(min_part=0, max_part=q, length=n) sage: list(L) [[1, 1, 1], [1, 1, 0], [1, 0, 1], [1, 0, 0], [0, 1, 1], [0, 1, 0], [0, 0, 1], [0, 0, 0]] Is something like this what you want? sage: q=1 sage ...