triClickAt [idc, u, v] — like triClick but presses at the local (u, v) point inside the control instead of its centre. Lets a test click PAST an edit field's text (clicking beyond a short line drove CEdit::XToPos off the end).
| 350 | // triClickAt [idc, u, v] — like triClick but presses at the local (u, v) point |
| 351 | // inside the control instead of its centre. Lets a test click PAST an edit |
| 352 | // field's text (clicking beyond a short line drove CEdit::XToPos off the end). |
| 353 | GameValue TriClickAt(const GameState* /*state*/, GameValuePar arg) |
| 354 | { |
| 355 | if (arg.GetType() != GameArray) |
| 356 | return GameValue(false); |
| 357 | const GameArrayType& a = arg; |
| 358 | if (a.Size() < 3) |
| 359 | return GameValue(false); |
| 360 | int idc = static_cast<int>(static_cast<GameScalarType>(a[0])); |
| 361 | float u = static_cast<float>(static_cast<GameScalarType>(a[1])); |
| 362 | float v = static_cast<float>(static_cast<GameScalarType>(a[2])); |
| 363 | auto* display = GetActiveDisplayForSQF(); |
| 364 | if (!display) |
| 365 | return GameValue(false); |
| 366 | if (!display->GetCtrl(idc)) |
| 367 | { |
| 368 | if (auto* owner = UIActiveDisplay::FindContainerWithIdc(GWorld, idc)) |
| 369 | display = owner; |
| 370 | } |
| 371 | auto* control = dynamic_cast<Control*>(display->GetCtrl(idc)); |
| 372 | if (!control) |
| 373 | return GameValue(false); |
| 374 | float x = control->X() + control->W() * u; |
| 375 | float y = control->Y() + control->H() * v; |
| 376 | LOG_INFO(Core, "[tri] triClickAt IDC={} at ({},{})", idc, x, y); |
| 377 | control->OnLButtonDown(x, y); |
| 378 | control->OnLButtonUp(x, y); |
| 379 | return GameValue(true); |
| 380 | } |
| 381 | |
| 382 | /// triInvokeButton <idc> — call the active display's OnButtonClicked(idc) |
nothing calls this directly
no test coverage detected