mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fix textbox scrolling
This commit is contained in:
parent
1d4abd7758
commit
bebb5049ef
3 changed files with 28 additions and 15 deletions
|
|
@ -43,20 +43,28 @@ std::shared_ptr<UINode> Container::getAt(const glm::vec2& pos) {
|
|||
return UINode::getAt(pos);
|
||||
}
|
||||
|
||||
void Container::click(int x, int y) {
|
||||
UINode::click(x, y);
|
||||
|
||||
if (scrollable) {
|
||||
auto pos = calcPos();
|
||||
x -= pos.x;
|
||||
y -= pos.y;
|
||||
if (x >= size.x - scrollBarWidth) {
|
||||
scrollbarTriggered = true;
|
||||
prevScrollY = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Container::mouseMove(int x, int y) {
|
||||
UINode::mouseMove(x, y);
|
||||
if (!scrollable) {
|
||||
if (!scrollable || !scrollbarTriggered) {
|
||||
return;
|
||||
}
|
||||
auto pos = calcPos();
|
||||
x -= pos.x;
|
||||
y -= pos.y;
|
||||
if (prevScrollY == -1) {
|
||||
if (x >= size.x - scrollBarWidth) {
|
||||
prevScrollY = y;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int diff = (actualLength-size.y);
|
||||
if (diff > 0) {
|
||||
scroll -= (y - prevScrollY) / static_cast<float>(size.y) * actualLength;
|
||||
|
|
@ -69,7 +77,7 @@ void Container::mouseMove(int x, int y) {
|
|||
|
||||
void Container::mouseRelease(int x, int y) {
|
||||
UINode::mouseRelease(x, y);
|
||||
prevScrollY = -1;
|
||||
scrollbarTriggered = false;
|
||||
}
|
||||
|
||||
void Container::act(float delta) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue