MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / onMouseUp

Method onMouseUp

src/openrct2-ui/scripting/CustomWindow.cpp:573–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571 }
572
573 void onMouseUp(WidgetIndex widgetIndex) override
574 {
575 switch (widgetIndex)
576 {
577 case WIDX_CLOSE:
578 {
579 auto* windowMgr = GetWindowManager();
580 windowMgr->Close(*this);
581 break;
582 }
583 default:
584 {
585 if (widgetIndex >= WIDX_TAB_0
586 && widgetIndex < static_cast<WidgetIndex>(WIDX_TAB_0 + _info.Desc.Tabs.size()))
587 {
588 ChangeTab(widgetIndex - WIDX_TAB_0);
589 break;
590 }
591
592 const auto widgetDesc = _info.GetCustomWidgetDesc(this, widgetIndex);
593 if (widgetDesc != nullptr)
594 {
595 if (widgetDesc->Type == "button")
596 {
597 InvokeEventHandler(_info.Owner, widgetDesc->OnClick);
598 }
599 else if (widgetDesc->Type == "checkbox")
600 {
601 auto& widget = widgets[widgetIndex];
602 widget.flags.flip(WidgetFlag::isPressed);
603 bool isChecked = widget.flags.has(WidgetFlag::isPressed);
604
605 widgetSetCheckboxValue(*this, widgetIndex, isChecked);
606
607 std::vector<JSValue> args;
608 args.push_back(JS_NewBool(widgetDesc->OnChange.context, isChecked));
609 InvokeEventHandler(_info.Owner, widgetDesc->OnChange, args);
610 }
611 else if (widgetDesc->Type == "spinner")
612 {
613 auto& widget = widgets[widgetIndex];
614 if (widget.text != STR_NUMERIC_DOWN && widget.text != STR_NUMERIC_UP)
615 {
616 InvokeEventHandler(_info.Owner, widgetDesc->OnClick);
617 }
618 }
619 }
620 break;
621 }
622 }
623 }
624
625 void onMouseDown(WidgetIndex widgetIndex) override
626 {

Callers

nothing calls this directly

Calls 9

GetWindowManagerFunction · 0.85
InvokeEventHandlerFunction · 0.85
widgetSetCheckboxValueFunction · 0.85
GetCustomWidgetDescMethod · 0.80
flipMethod · 0.80
hasMethod · 0.65
CloseMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected