1616namespace {
1717 using namespace Wt ;
1818
19+ int asInt (const std ::string & v ) {
20+ return boost ::lexical_cast < int > (v );
21+ }
22+
1923 int parseIntParameter (const WebRequest & request , const std ::string & name ,
2024 int ifMissing ) {
2125 const std ::string * p ;
2226
2327 if ((p = request .getParameter (name ))) {
2428 try {
25- return boost :: lexical_cast < int > (* p );
29+ return asInt (* p );
2630 } catch (const boost ::bad_lexical_cast & ee ) {
2731 wApp -> log ("error" ) << "Could not cast event property '" << name
2832 << ": " << * p << "' to int" ;
@@ -41,10 +45,50 @@ namespace {
4145 } else
4246 return std ::string ();
4347 }
48+
49+ void decodeTouches (std ::string str , std ::vector < Touch > & result ) {
50+ if (str .empty ())
51+ return ;
52+
53+ std ::vector < std ::string > s ;
54+ boost ::split (s , str , boost ::is_any_of (";" ));
55+
56+ if (s .size () % 9 ) {
57+ wApp -> log ("error" ) << "Could not parse touches array '" << str << "'" ;
58+ return ;
59+ }
60+
61+ try {
62+ for (unsigned i = 0 ; i < s .size (); i += 9 ) {
63+ result .push_back (Touch (asInt (s [i + 0 ]),
64+ asInt (s [i + 1 ]), asInt (s [i + 2 ]),
65+ asInt (s [i + 3 ]), asInt (s [i + 4 ]),
66+ asInt (s [i + 5 ]), asInt (s [i + 6 ]),
67+ asInt (s [i + 7 ]), asInt (s [i + 8 ])));
68+ }
69+ } catch (const boost ::bad_lexical_cast & ee ) {
70+ wApp -> log ("error" ) << "Could not parse touches array '" << str << "'" ;
71+ return ;
72+ }
73+ }
4474}
4575
4676namespace Wt {
4777
78+ Touch ::Touch (int identifier ,
79+ int clientX , int clientY ,
80+ int documentX , int documentY ,
81+ int screenX , int screenY ,
82+ int widgetX , int widgetY )
83+ : identifier_ (identifier ),
84+ clientX_ (clientX ),
85+ clientY_ (clientY ),
86+ documentX_ (documentX ),
87+ documentY_ (documentY ),
88+ widgetX_ (widgetX ),
89+ widgetY_ (widgetY )
90+ { }
91+
4892JavaScriptEvent ::JavaScriptEvent ()
4993{ }
5094
@@ -124,6 +168,10 @@ void JavaScriptEvent::get(const WebRequest& request, const std::string& se)
124168 (getStringParameter (request , se + "a"
125169 + boost ::lexical_cast < std ::string > (i )));
126170 }
171+
172+ decodeTouches (getStringParameter (request , se + "touches" ), touches );
173+ decodeTouches (getStringParameter (request , se + "ttouches" ), targetTouches );
174+ decodeTouches (getStringParameter (request , se + "ctouches" ), changedTouches );
127175}
128176
129177WMouseEvent ::WMouseEvent ()
@@ -229,4 +277,15 @@ WTouchEvent::WTouchEvent(const JavaScriptEvent& jsEvent)
229277WTouchEvent WTouchEvent ::templateEvent ;
230278#endif // WT_TARGET_JAVA;
231279
280+ WGestureEvent ::WGestureEvent ()
281+ { }
282+
283+ WGestureEvent ::WGestureEvent (const JavaScriptEvent & jsEvent )
284+ : jsEvent_ (jsEvent )
285+ { }
286+
287+ #ifdef WT_TARGET_JAVA
288+ WGestureEvent WGestureEvent ::templateEvent ;
289+ #endif // WT_TARGET_JAVA;
290+
232291}
0 commit comments