MCPcopy Create free account
hub / github.com/WheretIB/nullc / OnLeftMouseDown

Method OnLeftMouseDown

GUI/RichTextarea.cpp:2233–2278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2231}
2232
2233void TextareaData::OnLeftMouseDown(unsigned int x, unsigned int y)
2234{
2235 unsigned int startX, startY, endX, endY;
2236
2237 // Capture mouse
2238 SetCapture(areaWnd);
2239 // Remove cursor
2240 RichTextarea::AreaCursorUpdate(areaWnd, 0, NULL, 0);
2241 // Reset I-bar tick count
2242 ibarState = 0;
2243 // When left mouse button is pressed, disable selection mode and save position as selection start
2244 if(selectionOn && !IsPressed(VK_SHIFT))
2245 {
2246 selectionOn = false;
2247 // Sort selection range
2248 SortSelPoints(startX, endX, startY, endY);
2249 // Force selected part redraw
2250 RECT invalid = { 0, (startY - shiftCharY) * RichTextarea::charHeight, areaWidth, (endY - shiftCharY + 1) * RichTextarea::charHeight };
2251 InvalidateRect(areaWnd, &invalid, false);
2252 }
2253 if(IsPressed(VK_SHIFT))
2254 {
2255 // If there is no selection, start it
2256 if(!selectionOn)
2257 {
2258 dragStartX = cursorCharX;
2259 dragStartY = cursorCharY;
2260 }
2261 // Update end of selection
2262 currLine = ClientToCursor(x, y, dragEndX, dragEndY, true);
2263 cursorCharX = dragEndX;
2264 cursorCharY = dragEndY;
2265 selectionOn = true;
2266 InvalidateRect(areaWnd, NULL, false);
2267 }else if(IsPressed(VK_CONTROL)){
2268 currLine = ExtendSelectionFromPoint(x, y);
2269 cursorCharX = dragEndX;
2270 cursorCharY = dragEndY;
2271 InvalidateRect(areaWnd, NULL, false);
2272 }else{
2273 // Set drag start and cursor position to where the user have clicked
2274 currLine = ClientToCursor(x, y, dragStartX, dragStartY, true);
2275 cursorCharX = dragStartX;
2276 cursorCharY = dragStartY;
2277 }
2278}
2279
2280void TextareaData::OnMouseMove(unsigned int x, unsigned int y)
2281{

Callers 1

TextareaProcMethod · 0.80

Calls 1

IsPressedFunction · 0.70

Tested by

no test coverage detected