Double tap not working on Win8 tablet?

  • Using Windows 8, a double click by way of the mouse works fine, however double tapping the touch screen does not invoke the doubleclick event... neither the OnTextObjectDblClick nor the OnDblClick event gets fired.

    Double-tap works fine for other controls, just not inside the editor.

    HELP!!

    (Note: double tap with Windows 7 worked fine on the same Acer W500 tablet, but not after updating it to Win8. So, this is a Win8 related issue with WPTools it appears, and is being reported by ALL our users that have Win8 tablets)

    Edit: Additional info...

    I looked at the window messages, and a mouse double click is doing this:
    WM_LBUTTONDOWN
    WM_LBUTTONUP
    WM_LBUTTONDOWN
    WM_LBUTTONUP
    WP_LBUTTONDBLCLK

    However, a double tap under Win8 is doing this:
    WM_LBUTTONDOWN
    WM_LBUTTONUP
    WP_LBUTTONDBLCLK
    WM_LBUTTONUP

    If what I suspect is true, then the TWPCustomRtfEdit.Click handler in WPCTRMemo is only being entered once and therefore never sees the 2nd click to determine if it should be considered a double click or not.

    If you concur... how can we fix this?!

    Eric

  • Bummer... but we all know you really want one of those new Windows 8 Pro tablets ;)

    Note that it also fails using a desktop touch screen monitor. But I'll see if I can work it out on my end and pass it on to you.

    Eric

  • Julian,
    I think I have it worked out... at least it seems to work on my desktop which as a touch screen and my Acer W500 tablet, both are on Windows 8 Pro.


    Notice that I added in the DblClick event handler, and migrated that logic from your Click handler over to it while still maintaining Triple click support using the mouse (word, sentence, paragraph selection process)... not sure why triple taps don't, but not important to me for now as I have to move on and double tapping an image on a tablet was VERY important!

    Note also that my mods were based on the WPTools 5.58.1 codeline. I didn't see much difference in this section between v6 and v5.81.1, so I didn't bother to integrate v6 in yet.

  • Unfortunately I found one bug (so far) with my implementation. If I disable OneClickHyperlink and I invoke a dialog in the HyperlinkEvent, the WPRichText thinks I'm selecting text and text gets highlighted as I drag the mouse around once the dialog is closed.

    No problem unless I invoke a dialog on a double click hyperlink, and no problem if OneClickHyperlink is true, so it is related to the DblClick path.

    Do you know offhand what I missed? I'll keep looking.

  • OK... once again, I think I have it worked out and fixed the problem I was having. Below is the revised code:

    First I added a new Boolean (added just under _FAfterTextObjectClick):

    Code
    _FAfterDblClick: Boolean;


    Then the two updated routines:

    Code
    procedure TWPCustomRtfEdit.DblClick;var  vIgnore: Boolean;  vTextObj: TWPTextObj;begin  if FLastMouseWasDrag or FInMouseDown or _3rdParty_MouseLock then    exit;  _FAfterDblClick := TRUE;  if assigned(FOnTextObjectDblClick) then  begin    if FTextObjectUnderMouse <> nil then      vTextObj := FTextObjectUnderMouse    else if not CodeObjectAtXY(FClientMouseX, FClientMouseY, vTextObj) then      vTextObj := nil;    if (vTextObj <> nil) and not (FLastMovedObject = vTextObj) then    begin      vIgnore := FALSE;      FOnTextObjectDblClick(Self, vTextObj, vTextObj.ObjRef, vIgnore);      if vIgnore then        exit;      HideSelection;      RePaint;    end;  end;  FLastMovedObject := nil;  DoDblClick(MousePage, FMouseX, FMouseY);  if not (wpDisableSelection in EditoptionsEx) then    StartUpdate(WPUPD_UPDSELECTION);end;procedure TWPCustomRtfEdit.Click;var  vMaxTickCount, vDblClickTime: DWord;  vIsDblClick, vIgnore: Boolean;  vTextObj: TWPTextObj;  vMsg: Windows.TMsg;  vScreenCP, vClientCP: TPoint;  vHideSelection: Boolean;  vPar: TParagraph;  vPosInPar: Integer;begin  if FLastMouseWasDrag or FInMouseDown or _3rdParty_MouseLock then    exit;  vIsDblClick := FALSE;  vIgnore := FALSE;  vScreenCP := Mouse.CursorPos;  vClientCP := ScreenToClient(vScreenCP);  vHideSelection := (GetAsyncKeyState(FVKLeftMouseButton) >= 0);  { We need to check if we are at selection to make triple click possible }  if not (wpDisableSelection in EditOptionsEx) and    vHideSelection and TextCursor.IsSelected(false) and    not GetLineFromXY(vClientCP.x, vClientCP.y, vPar, vPosInPar) and    not FMemo.Cursor.IsTextSelected(vPar, vPosInPar) and    (FTextObjectUnderMouse = nil) //V5.22.1  then  begin    HideSelection;    RePaint;    vHideSelection := FALSE;  end;  // Now check for KeyPress and DblClick events to abort loop at once  vDblClickTime := GetDoubleClickTime();  if vDblClickTime > 200 then    vDblClickTime := 200; // Typical DoubleClickTime=500ms, causes LONG delay!  vMaxTickCount := GetTickCount + vDblClickTime;  while (not vIsDblClick) and (not vIgnore) and (GetTickCount < vMaxTickCount) do  begin    if PeekMessage(vMsg, Handle, WM_LBUTTONDBLCLK, WM_LBUTTONDBLCLK, PM_NOREMOVE) then      vIsDblClick := TRUE    else if PeekMessage(vMsg, Handle, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE) then      vIgnore := TRUE;  end;  if (GetAsyncKeyState(FVKLeftMouseButton) >= 0) then    vHideSelection := TRUE; // Left mouse button is not down  if vIsDblClick then    exit;  if (vHideSelection)  //V5.22 Mouse Up!     and (not (wpDisableSelection in EditOptionsEx))     and (IsSelected)     and (FTextObjectUnderMouse = nil)     and (FMouseSelectCell = nil)     and ((FMouseClickFrameBorder * [wpClickLeftMargin, wpClickRightMargin]) = [])  then  begin    HideSelection;    RePaint;  end;  if assigned(FOnTextObjectClick) then  begin    if FTextObjectUnderMouse <> nil then      vTextObj := FTextObjectUnderMouse    else if not CodeObjectAtXY(FClientMouseX, FClientMouseY, vTextObj) then      vTextObj := nil;    if (vTextObj <> nil) and not (FLastMovedObject = vTextObj) then    begin      vIgnore := FALSE;      FOnTextObjectClick(Self, vTextObj, vTextObj.ObjRef, vIgnore);      if vIgnore then      begin        _FAfterTextObjectClick := TRUE;        exit;      end;    end;  end;  FLastMovedObject := nil;  if Memo.HasData then  begin    if not (wpDisableSelection in EditoptionsEx)      and (GetTickCount > FLastSelectionChange)      and (GetAsyncKeyState(FVKLeftMouseButton) > 0)      and not (SelectedObject <> nil)      and (FMouseSelectCell = nil)    then      HideSelection;    DoClickPage(MousePage);    if FMemo._HasSelectionPaint then      StartUpdate(WPUPD_REPAINT);    DoClick(MousePage, FMouseX, FMouseY);  end;  if not (wpDisableSelection in EditoptionsEx) then    StartUpdate(WPUPD_UPDSELECTION);end;


    Plus added this to the beginning of TWPCustomRtfEdit.MouseDown because a control's WMLButtonDblClk event calls DoMouseDown:

    Code
    if _FAfterDblClick then
      begin
        _FAfterDblClick := false;
        exit;
      end;


    I'll keep you posted should I run into more issues.