mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
[MSPAINT] Move selection by arrow keys (#5334)
Improve keyboard usability. - Add CCanvasWindow::MoveSelection. - Modify CMainWindow::OnKeyDown. - If Esc key is pressed, then the selection will land to canvas. - If any arrow key is pressed, then the selection will move a bit. CORE-18867
This commit is contained in:
parent
0087ea6597
commit
1a88607387
3 changed files with 41 additions and 8 deletions
|
@ -777,6 +777,16 @@ VOID CCanvasWindow::EndSelectionDrag(POINT ptImage)
|
|||
Invalidate(FALSE);
|
||||
}
|
||||
|
||||
VOID CCanvasWindow::MoveSelection(INT xDelta, INT yDelta)
|
||||
{
|
||||
if (!selectionModel.m_bShow)
|
||||
return;
|
||||
|
||||
selectionModel.TakeOff();
|
||||
::OffsetRect(&selectionModel.m_rc, xDelta, yDelta);
|
||||
Invalidate(FALSE);
|
||||
}
|
||||
|
||||
LRESULT CCanvasWindow::OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
SetTextColor((HDC)wParam, paletteModel.GetFgColor());
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
VOID CanvasToImage(POINT& pt, BOOL bZoomed = FALSE);
|
||||
VOID CanvasToImage(RECT& rc, BOOL bZoomed = FALSE);
|
||||
VOID GetImageRect(RECT& rc);
|
||||
VOID MoveSelection(INT xDelta, INT yDelta);
|
||||
|
||||
protected:
|
||||
CANVAS_HITTEST m_hitSelection;
|
||||
|
|
|
@ -493,17 +493,39 @@ LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
|
|||
|
||||
LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (wParam == VK_ESCAPE)
|
||||
HWND hwndCapture;
|
||||
switch (wParam)
|
||||
{
|
||||
HWND hwndCapture = GetCapture();
|
||||
if (hwndCapture)
|
||||
{
|
||||
if (canvasWindow.m_hWnd == hwndCapture ||
|
||||
fullscreenWindow.m_hWnd == hwndCapture)
|
||||
case VK_ESCAPE:
|
||||
hwndCapture = GetCapture();
|
||||
if (hwndCapture)
|
||||
{
|
||||
SendMessage(hwndCapture, nMsg, wParam, lParam);
|
||||
if (canvasWindow.m_hWnd == hwndCapture ||
|
||||
fullscreenWindow.m_hWnd == hwndCapture)
|
||||
{
|
||||
SendMessage(hwndCapture, nMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (selectionModel.m_bShow)
|
||||
{
|
||||
selectionModel.Landing();
|
||||
selectionModel.m_bShow = FALSE;
|
||||
canvasWindow.Invalidate(FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_LEFT:
|
||||
canvasWindow.MoveSelection(-1, 0);
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
canvasWindow.MoveSelection(+1, 0);
|
||||
break;
|
||||
case VK_UP:
|
||||
canvasWindow.MoveSelection(0, -1);
|
||||
break;
|
||||
case VK_DOWN:
|
||||
canvasWindow.MoveSelection(0, +1);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue