MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetClicked

Method SetClicked

src/widget.cpp:1957–1967  ·  view source on GitHub ↗

* Sets the clicked element in the matrix. * @param clicked The clicked element. */

Source from the content-addressed store, hash-verified

1955 * @param clicked The clicked element.
1956 */
1957void NWidgetMatrix::SetClicked(int clicked)
1958{
1959 this->clicked = clicked;
1960 if (this->clicked >= 0 && this->sb != nullptr && this->widgets_x != 0) {
1961 int vpos = (this->clicked / this->widgets_x) * this->widget_h; // Vertical position of the top.
1962 /* Need to scroll down -> Scroll to the bottom.
1963 * However, last entry has no 'this->pip_inter' underneath, and we must stay below this->sb->GetCount() */
1964 if (this->sb->GetPosition() < vpos) vpos += this->widget_h - this->pip_inter - 1;
1965 this->sb->ScrollTowards(vpos);
1966 }
1967}
1968
1969/**
1970 * Set the number of elements in this matrix.

Callers 2

UpdateButtonsMethod · 0.80

Calls 2

GetPositionMethod · 0.80
ScrollTowardsMethod · 0.80

Tested by

no test coverage detected