diff options
author | Jan Holesovsky <kendy@collabora.com> | 2022-10-24 16:27:17 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2022-11-03 21:52:40 +0100 |
commit | 142d3e15916afd1c38bcccf0d23cac292ea357fc (patch) | |
tree | e2ac26390baa3768fa374547a4cd675fe9ecb9ff /sc | |
parent | 6c0ac70a512c1789d26721bd1f7d01a8b24fa718 (diff) |
sc lok: Double-click should behave more like on desktop
When editing was introduced in Calc LibreOfficeKit, there were lots of
limitations. Particularly the thinking was that it would be good if a
double-click into any text (even if spanning over more cells)
actually started editing that text.
These days, the LOK behaves much more consistently, so it is better to
behave as the LibreOffice on desktop (or other tools, like gdocs) do:
If the cell:
* Is empty
-> single click places the cell cursor
-> double click places the cell cursor & shows the text caret
* Is empty, but covered by text bleeding from other cell
-> same as if it was empty
* Isn't empty
-> single click places the cell cursor
-> double click places the cell cursor & places the text caret
inside the text where the user clicked
+ this is actually different in gdocs - there the caret is
placed at the end of the text; in LO it is where the user has
double-clicked
Change-Id: Ib5884f887c98f803b06d8bed5057ec435be480ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142196
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 69a1daf6f9ce..1ae16dd962aa 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1833,49 +1833,6 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta if ( !nButtonDown || !bDouble ) // single (first) click is always valid nButtonDown = rMEvt.GetButtons(); // set nButtonDown first, so StopMarking works - // special handling of empty cells with tiled rendering - if (bIsTiledRendering) - { - Point aPos(rMEvt.GetPosPixel()); - SCCOL nPosX, nNonEmptyX(0); - SCROW nPosY; - SCTAB nTab = mrViewData.GetTabNo(); - mrViewData.GetPosFromPixel(aPos.X(), aPos.Y(), eWhich, nPosX, nPosY); - - ScRefCellValue aCell(rDoc, ScAddress(nPosX, nPosY, nTab)); - bool bIsEmpty = aCell.isEmpty(); - bool bIsCoveredByText = bIsEmpty && IsCellCoveredByText(nPosX, nPosY, nTab, nNonEmptyX); - - if (bIsCoveredByText) - { - // if there's any text flowing to this cell, activate the - // editengine, so that the text actually gets the events - if (bDouble) - { - ScViewFunc* pView = mrViewData.GetView(); - - pView->SetCursor(nNonEmptyX, nPosY); - SC_MOD()->SetInputMode(SC_INPUT_TABLE); - - bEditMode = mrViewData.HasEditView(eWhich); - assert(bEditMode); - - // synthesize the 1st click - EditView* pEditView = mrViewData.GetEditView(eWhich); - MouseEvent aEditEvt(rMEvt.GetPosPixel(), 1, MouseEventModifiers::SYNTHETIC, MOUSE_LEFT, 0); - pEditView->MouseButtonDown(aEditEvt); - pEditView->MouseButtonUp(aEditEvt); - } - } - else if (bIsEmpty && bEditMode && bDouble) - { - // double-click in an empty cell: the entire cell is selected - SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aPos.X(), aPos.Y()); - SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aPos.X(), aPos.Y()); - return; - } - } - if ( ( bEditMode && mrViewData.GetActivePart() == eWhich ) || !bFormulaMode ) GrabFocus(); @@ -2406,14 +2363,11 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) mrViewData.GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); ScDPObject* pDPObj = rDoc.GetDPAtCursor( nPosX, nPosY, nTab ); - bool bInDataPilotTable = (pDPObj != nullptr); - // double click (only left button) - // in the tiled rendering case, single click works this way too bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive(); bool bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() ); - if ((bDouble || (bIsTiledRendering && !bInDataPilotTable)) + if ( bDouble && !bRefMode && (nMouseStatus == SC_GM_DBLDOWN || (bIsTiledRendering && nMouseStatus != SC_GM_URLDOWN)) && !pScMod->IsRefDialogOpen()) @@ -2473,19 +2427,8 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) bEditAllowed = false; } - // We don't want to activate the edit view for a single click in tiled rendering - // (but we should probably keep the same behaviour for double clicks). - if ( bEditAllowed && (!bIsTiledRendering || bDouble) ) + if ( bEditAllowed ) { - // don't forward the event to an empty cell, causes deselection in - // case we used the double-click to select the empty cell - if (bIsTiledRendering && bDouble) - { - ScRefCellValue aCell(mrViewData.GetDocument(), ScAddress(nPosX, nPosY, nTab)); - if (aCell.isEmpty()) - return; - } - // edit cell contents mrViewData.GetViewShell()->UpdateInputHandler(); pScMod->SetInputMode( SC_INPUT_TABLE ); |