MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / TriClickAt

Function TriClickAt

engine/Poseidon/Game/Commands/GameStateExtTest.cpp:352–379  ·  view source on GitHub ↗

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).

Source from the content-addressed store, hash-verified

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).
353GameValue 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)

Callers

nothing calls this directly

Calls 12

GetActiveDisplayForSQFFunction · 0.85
FindContainerWithIdcFunction · 0.85
GameValueClass · 0.50
GetTypeMethod · 0.45
SizeMethod · 0.45
GetCtrlMethod · 0.45
XMethod · 0.45
WMethod · 0.45
YMethod · 0.45
HMethod · 0.45
OnLButtonDownMethod · 0.45
OnLButtonUpMethod · 0.45

Tested by

no test coverage detected