sw lok: fix blinking cursor position of comments
With this, it is possible to click inside a comment (and get a blinking cursor inside a comment), and also possible to use the arrow keys to native around and still get correct blinking cursor position. Change-Id: I29eb1e60e4e571151f0b18bec8cf765ea09af09f
This commit is contained in:
@@ -178,9 +178,10 @@ class SwSidebarWin : public vcl::Window
|
|||||||
|
|
||||||
virtual void Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override;
|
virtual void Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override;
|
||||||
virtual void KeyInput(const KeyEvent& rKeyEvt) override;
|
virtual void KeyInput(const KeyEvent& rKeyEvt) override;
|
||||||
|
virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override;
|
||||||
void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
|
void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
|
||||||
/// Get the matching sub-widget inside this sidebar widget for rPointLogic, if any.
|
/// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
|
||||||
vcl::Window* IsHitWindow(const Point& rPointLogic);
|
bool IsHitWindow(const Point& rPointLogic);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DataChanged( const DataChangedEvent& aEvent) override;
|
virtual void DataChanged( const DataChangedEvent& aEvent) override;
|
||||||
|
@@ -1736,9 +1736,9 @@ vcl::Window* SwPostItMgr::IsHitSidebarWindow(const Point& rPointLogic)
|
|||||||
if (!pPostIt)
|
if (!pPostIt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (vcl::Window* pWindow = pPostIt->IsHitWindow(rPointLogic))
|
if (pPostIt->IsHitWindow(rPointLogic))
|
||||||
{
|
{
|
||||||
pRet = pWindow;
|
pRet = pPostIt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,6 @@ class SidebarTextControl : public Control
|
|||||||
protected:
|
protected:
|
||||||
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
|
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
|
||||||
virtual void MouseMove( const MouseEvent& rMEvt ) override;
|
virtual void MouseMove( const MouseEvent& rMEvt ) override;
|
||||||
virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
|
|
||||||
virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
|
virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
|
||||||
virtual void Command( const CommandEvent& rCEvt ) override;
|
virtual void Command( const CommandEvent& rCEvt ) override;
|
||||||
virtual void LoseFocus() override;
|
virtual void LoseFocus() override;
|
||||||
@@ -61,6 +60,7 @@ class SidebarTextControl : public Control
|
|||||||
|
|
||||||
virtual void GetFocus() override;
|
virtual void GetFocus() override;
|
||||||
virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
|
virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
|
||||||
|
virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override;
|
||||||
|
|
||||||
OutlinerView* GetTextView() const;
|
OutlinerView* GetTextView() const;
|
||||||
|
|
||||||
|
@@ -279,12 +279,10 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle
|
|||||||
rRenderContext.Push(PushFlags::NONE);
|
rRenderContext.Push(PushFlags::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
vcl::Window* SwSidebarWin::IsHitWindow(const Point& rPointLogic)
|
bool SwSidebarWin::IsHitWindow(const Point& rPointLogic)
|
||||||
{
|
{
|
||||||
Rectangle aRectangleLogic(EditWin().PixelToLogic(GetPosPixel()), EditWin().PixelToLogic(GetSizePixel()));
|
Rectangle aRectangleLogic(EditWin().PixelToLogic(GetPosPixel()), EditWin().PixelToLogic(GetSizePixel()));
|
||||||
if (aRectangleLogic.IsInside(rPointLogic))
|
return aRectangleLogic.IsInside(rPointLogic);
|
||||||
return mpSidebarTextControl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags)
|
void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags)
|
||||||
@@ -355,10 +353,40 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// We want to work in absolute twips: so set delta between rChild and rParent as origin on rChild, then disable map mode on rChild.
|
||||||
|
static void lcl_setAbsoluteTwips(vcl::Window& rParent, vcl::Window& rChild)
|
||||||
|
{
|
||||||
|
Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
|
||||||
|
MapMode aMapMode(rChild.GetMapMode());
|
||||||
|
aMapMode.SetOrigin(rChild.PixelToLogic(aOffset));
|
||||||
|
rChild.SetMapMode(aMapMode);
|
||||||
|
rChild.EnableMapMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
|
void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
|
||||||
{
|
{
|
||||||
if (mpSidebarTextControl)
|
if (mpSidebarTextControl)
|
||||||
|
{
|
||||||
|
mpSidebarTextControl->Push(PushFlags::MAPMODE);
|
||||||
|
lcl_setAbsoluteTwips(EditWin(), *mpSidebarTextControl);
|
||||||
|
|
||||||
mpSidebarTextControl->KeyInput(rKeyEvent);
|
mpSidebarTextControl->KeyInput(rKeyEvent);
|
||||||
|
|
||||||
|
mpSidebarTextControl->Pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent)
|
||||||
|
{
|
||||||
|
if (mpSidebarTextControl)
|
||||||
|
{
|
||||||
|
mpSidebarTextControl->Push(PushFlags::MAPMODE);
|
||||||
|
lcl_setAbsoluteTwips(EditWin(), *mpSidebarTextControl);
|
||||||
|
|
||||||
|
mpSidebarTextControl->MouseButtonDown(rMouseEvent);
|
||||||
|
|
||||||
|
mpSidebarTextControl->Pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
|
void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
|
||||||
|
@@ -2778,14 +2778,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
|
|||||||
{
|
{
|
||||||
if (vcl::Window* pWindow = m_rView.GetPostItMgr()->IsHitSidebarWindow(rMEvt.GetPosPixel()))
|
if (vcl::Window* pWindow = m_rView.GetPostItMgr()->IsHitSidebarWindow(rMEvt.GetPosPixel()))
|
||||||
{
|
{
|
||||||
bool bDisableMapMode = pWindow->IsMapModeEnabled();
|
|
||||||
if (bDisableMapMode)
|
|
||||||
pWindow->EnableMapMode(false);
|
|
||||||
|
|
||||||
pWindow->MouseButtonDown(rMEvt);
|
pWindow->MouseButtonDown(rMEvt);
|
||||||
|
|
||||||
if (bDisableMapMode)
|
|
||||||
pWindow->EnableMapMode();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user