@@ -55,7 +55,7 @@ WTableView::WTableView()
5555 plainTable_ (nullptr ),
5656 dropEvent_ (impl_ , "dropEvent" ),
5757 scrolled_ (impl_ , "scrolled" ),
58- itemTouchEvent_ (impl_ , "itemTouchEvent " ),
58+ itemTouchSelectEvent_ (impl_ , "itemTouchSelectEvent " ),
5959 firstColumn_ (-1 ),
6060 lastColumn_ (-1 ),
6161 viewportLeft_ (0 ),
@@ -790,8 +790,8 @@ void WTableView::defineJavaScript()
790790 if (!scrolled_ .isConnected ())
791791 scrolled_ .connect (this , & WTableView ::onViewportChange );
792792
793- if (!itemTouchEvent_ .isConnected ())
794- itemTouchEvent_ .connect (this , & WTableView ::handleTouchStarted );
793+ if (!itemTouchSelectEvent_ .isConnected ())
794+ itemTouchSelectEvent_ .connect (this , & WTableView ::handleTouchSelected );
795795
796796 if (!columnResizeConnected_ ) {
797797 columnResized ().connect (this , & WTableView ::onColumnResize );
@@ -869,6 +869,18 @@ void WTableView::render(WFlags<RenderFlag> flags)
869869 (this , std ::bind (& WTableView ::handleRootDoubleClick , this , 0 ,
870870 std ::placeholders ::_1 ));
871871 }
872+
873+ if (!touchStartConnection_ .isConnected ()
874+ && touchStarted ().isConnected ()) {
875+ touchStartConnection_ = canvas_ -> touchStarted ()
876+ .connect (std ::bind (& WTableView ::handleTouchStarted , this , std ::placeholders ::_1 ));
877+ }
878+
879+ if (!touchEndConnection_ .isConnected ()
880+ && touchEnded ().isConnected ()) {
881+ touchEndConnection_ = canvas_ -> touchEnded ()
882+ .connect (std ::bind (& WTableView ::handleTouchEnded , this , std ::placeholders ::_1 ));
883+ }
872884 }
873885
874886 if (model ())
@@ -1737,15 +1749,35 @@ void WTableView::handleMouseWentUp(bool headerColumns, const WMouseEvent& event)
17371749 handleMouseUp (index , event );
17381750}
17391751
1740- void WTableView ::handleTouchStarted (const WTouchEvent & event )
1752+ void WTableView ::handleTouchSelected (const WTouchEvent & event )
17411753{
17421754 std ::vector < WModelIndex > indices ;
17431755 for (std ::size_t i = 0 ; i < event .touches ().size (); i ++ ){
17441756 indices .push_back (translateModelIndex (event .touches ()[i ]));
17451757 }
1758+ handleTouchSelect (indices , event );
1759+ }
1760+
1761+ void WTableView ::handleTouchStarted (const WTouchEvent & event )
1762+ {
1763+ std ::vector < WModelIndex > indices ;
1764+ const std ::vector < Touch > & touches = event .changedTouches ();
1765+ for (std ::size_t i = 0 ; i < touches .size (); i ++ ){
1766+ indices .push_back (translateModelIndex (touches [i ]));
1767+ }
17461768 handleTouchStart (indices , event );
17471769}
17481770
1771+ void WTableView ::handleTouchEnded (const WTouchEvent & event )
1772+ {
1773+ std ::vector < WModelIndex > indices ;
1774+ const std ::vector < Touch > & touches = event .changedTouches ();
1775+ for (std ::size_t i = 0 ; i < touches .size (); i ++ ) {
1776+ indices .push_back (translateModelIndex (touches [i ]));
1777+ }
1778+ handleTouchEnd (indices , event );
1779+ }
1780+
17491781void WTableView ::handleRootSingleClick (int u , const WMouseEvent & event )
17501782{
17511783 handleClick (WModelIndex (), event );
0 commit comments